[Haskell-cafe] "Assignment" in do blocks?

Anupam Jain ajnsit at gmail.com
Thu Aug 27 14:09:29 UTC 2015


On Wed, Aug 26, 2015 at 8:14 PM, Tobias Dammers <tdammers at gmail.com> wrote:
> IMO, having <- in do syntax look like assignment is bad enough as it is,
> no need to further enforce the illusion.

The syntax could be anything, it doesn't have to be an arrow. For
example it could simply be an inbuilt function say `liftIdentity`.
i.e.

    foo <- liftIdentity $ bar foo

This makes sense if we think of every monad as a transformer around
the Identity monad. Analogous to liftIO, except automatically defined
for all Monads. Of course GHC would have to implement it in such a way
so as to not use `return`.

>
> The variable shadowing that effectively occurs in that example is still
> just as bad as regular shadowing.

I'm not sure how "shadowing" is bad. It is certainly safer than a
string of foo, foo', foo'' etc.


More information about the Haskell-Cafe mailing list