[Haskell-cafe] Re: Remember the future  Benjamin Franksen
benjamin.franksen at bessy.de Sat Aug 18 10:32:17 EDT 2007
Andrew Coppin wrote: > Surely all this means is that the magical
"mdo" keyword makes the  > compiler arbitrarily reorder the
expression...?  It is not magical but simple syntactic sugar.
And no, the compiler does not 'arbitrarily reorder' anything,
you do the same in any imperative language with
pointers/references and mutation.  >From the ghc manual:  7.3.3.
The recursive do-notation  The do-notation of Haskell does not
allow recursive bindings, that is, the variables are visible in
the entire binding group. It turns out that several applications
can benefit from recursive bindings in the do-notation, and this
extension provides the necessary syntactic support.  Here is a
simple (yet contrived) example:  import Control.Monad.Fix
justOnes = mdo xs <- Just (1:xs)                return xs   As
you can guess justOnes will evaluate to Just [1,1,1,....   The
Control.Monad.Fix library introduces th