[Haskell-cafe] Can I destructive rebind a local variable in
qdunkan at gmail.com
Tue Jan 6 03:33:15 EST 2009
> Nice. Good solution. ``imperative style'' is not a bad idea when I'm
> not used to the ``pure functional style''
> 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.
More information about the Haskell-Cafe