
Simon Peyton Jones wrote:
Recursive do-notation. ~~~~~~~~~~~~~~~~~~~~~~ The change is this. Instead of writing
mdo { a <- getChar ; b <- f c ; c <- g b ; putChar c ; return b }
you would write
do { a <- getChar ; rec { b <- f c ; c <- g b } ; putChar c ; return b }
That is, * 'mdo' is eliminated * 'rec' is added, which groups a bunch of statements into a single recursive statement See http://hackage.haskell.org/trac/ghc/ticket/2798
This 'rec' thing is already present for the arrow notation, so it makes the two more uniform. Moreover, 'rec' lets you say more precisely where the recursion is (if you want to), whereas 'mdo' just says "there's recursion here somewhere". Lastly, all this works with rebindable syntax (which mdo does not).
The main question is not whether to make this change, but when.
This last point notwithstanding, I find the scoping rules very unintuitive! (b and c appear to escape their apparently nested scope.) Wolfram