haskell-cafe@haskell.org
[Top] [All Lists]

Re: [Haskell-cafe] Can I destructive rebind a local variable in haskell?

Subject: Re: [Haskell-cafe] Can I destructive rebind a local variable in haskell?
From: "Evan Laforge"
Date: Tue, 6 Jan 2009 16:33:15 +0800
>   Nice. Good solution.  ``imperative style'' is not a bad idea when I'm
> not used to the ``pure functional style''
>
> E.g.
>
>   filename  <- return $ combine filename "Makefile"
>
> Similar to the other imperative language
>
>   filename = joinPath(filename,"Makefile")

I wouldn't consider it particularly imperative, it's just variable
shadowing.  It desugars to calling a function with a parameter that
shadows the old variable.

Of course, you could say a more functional way would be to use
pointfree style or just nested calls to avoid naming the intermediate
values.  Then you can't intersperse IO actions... but it's good to
avoid doing that anyway.
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@xxxxxxxxxxx
http://www.haskell.org/mailman/listinfo/haskell-cafe

<Prev in Thread] Current Thread [Next in Thread>