<html><head></head><body><p dir="ltr">It actually isn't written anywhere, and multiple statements in a do actually don't have to be evaluated in in the order they're written, for monads in general.</p>
<p dir="ltr">For most monads though, the implementation of >>= examines the left argument sufficiently to force things to be evaluated in that order (at least to the level of the monad's constructors).</p>
<p dir="ltr">IO in particular is implemented such that the effects of everything on the left of the bind (or earlier in a do block) will have been carried out before any of the effects from the right of the bind (later in the do). But even in the IO monad laziness can "delay" evaluation of pure computation mixed in with the IO actions; it just can't change the order the actions are executed in.</p>
<br><br><div class="gmail_quote">On 15 April 2015 7:07:24 pm AEST, Jon Schneider <haskell@jschneider.net> wrote:<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<pre class="k9mail">Good morning all,<br /><br />I think I've got the hang of the way state is carried and fancy operators<br />work in monads but still have a major sticky issue.<br /><br />With lazy evaluation where is it written that if you write things with no<br />dependencies with a "do" things will be done in order ? Or isn't it ?<br /><br />Is it a feature of the language we're supposed to accept ?<br /><br />Is it something in the implementation of IO ?<br /><br />Is the do keyword more than just a syntactic sugar for a string of binds<br />and lambdas ?<br /><br />Jon<br /><br /><hr /><br />Haskell-Cafe mailing list<br />Haskell-Cafe@haskell.org<br /><a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe">http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe</a><br /></pre></blockquote></div></body></html>