
5 Feb
2009
5 Feb
'09
11:49 a.m.
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.