On 8/18/07, Andrew Coppin <[EMAIL PROTECTED]> wrote:

> Surely all this means is that the magical "mdo" keyword makes the
> compiler arbitrarily reorder the expression...?

What mdo actually does is described here:
http://www.cse.ogi.edu/PacSoft/projects/rmb/mdo.pdf

My last example desugars to:

test = mfix (
    \ ~(x,y,z,v) -> do
        z <- return $ x+y
        print "Hello"
        x <- readLn
        y <- readLn
        v <- return z
        return (x,y,z,v))
    >>= \(x,y,z,v) -> return v

So at core there really is a do-expression that's passing 'return $
x+y' into a print which in turn is passed into the 'readLn's.
--
Dan
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to