[Haskell-cafe] Monads, do and strictness

Steve Horne sh006d3592 at blueyonder.co.uk
Sat Jan 21 19:42:45 CET 2012

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".


   a >>= b -> f b


   return (f (unsafePerformIO a))

More information about the Haskell-Cafe mailing list