[Haskell-cafe] Re: evaluation semantics of bind

Gleb Alexeyev gleb.alexeev at gmail.com
Thu Feb 5 11:49:02 EST 2009

Gregg Reynolds wrote:
  > I must be misunderstanding something.  I don't know if it would be
> optimized out, but I see no reason why it couldn't be.  There's no data 
> dependency, right?

Of course there is data dependency. In my example, where IO is defined 
as a (generalized) algebraic datatype, the value of getChar is GetChar.
The value of 'getChar >>= \x -> getChar' is 'Bind GetChar (\x -> 
GetChar'. 'x' is not used anywhere, but this doesn't change the fact 
that these are totally different values, no sane compiler would prove 
them equal.

For some monads, the evaluation of 'a >>= \x -> b' yields b, but it's 
not true in general.

More information about the Haskell-Cafe mailing list