On 21/01/2012 18:08, Steve Horne wrote:
Even so, to see that strictness isn't the issue, imagine that (>>=)
were rewritten using a unary executeActionAndExtractResult function.
You could easily rewrite your lamba to contain this expression in
place of x, without actually evaluating that
executeActionAndExtractResult. You'd still be doing a form of
composition of IO actions. And when you finally did force the
evaluation of the complete composed expression, the ordering of side
effects would still be preserved - provided you only used that
function as an intermediate step in implementing (>>=) at least.
Doh!!! - that function *does* exist and is spelled "unsafePerformIO".
But AFAIK it isn't used for compilation/interpretation of (>>=) operators.
If it *were* used, the rewriting would also need an extra "return".
So...
a >>= b -> f b
becomes...
return (f (unsafePerformIO a))
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe