[Haskell-cafe] RE: monad subexpressions
cdsmith at twu.net
Fri Aug 3 13:39:11 EDT 2007
Simon Peyton-Jones <simonpj at microsoft.com> wrote:
> Furthermore there must be no lambda between the "monadic splice" and the "do".
I'm curious about this.
One could sugar:
do tax <- getTax
return $ map (\price -> price * (1 + tax)) bill
do return $ map (\price -> price * (1 + (<- getTax))) someNums
Do you not think this is desirable? Is there a negative side-effect
that I'm not noticing?
I sort of see this in the same boat as Neil's example with if/then/else.
The meaning may not be precisely what you'd expect... but mind-reading
is hard, and it's more consistent to just say "find the innermost
containing do block" than make up new rules for each piece of syntax.
Granted, a special case of "it's an error" is far more appealing than
the corresponding special case for if; but I don't yet see a reason for
this exception to the rule either.
More information about the Haskell-Cafe