[Haskell-cafe] >> and sequencing [newbie]
David Powers
david at grayskies.net
Sun Apr 15 20:04:41 EDT 2007
so... this is likely a question based on serious misunderstandings, but can
anyone help me understand the exact mechanism by which monads enforce
sequencing? Specifically, I'm confused by the >> operator. If I understand
things properly f a >> g expands to something like:
f >>= \_ -> g
What I'm missing is how the expansion of f is ever forced under lazy
evaluation. Since the result is never used, doesn't it just stay as a
completely unevaluated thunk? Come to think of it... how is it that some IO
actions sequence completely, while others manage to work in a lazy manner?
My suspicion is that somehow the order of evaluation in Haskell gives the
outermost expression a "first crack" at evaluation in all circumstances (e.g.
http://users.aber.ac.uk/afc/stricthaskell.html#cps) , but that it somehow
stops short of a forced deep sequencing... Which is all to say, I have no
idea how the magic happens.
-David
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20070415/940e8b09/attachment.htm
More information about the Haskell-Cafe
mailing list