<br><br><div class="gmail_quote">On Mon, Feb 9, 2009 at 7:17 AM, Lennart Augustsson <span dir="ltr">&lt;<a href="mailto:lennart@augustsson.net">lennart@augustsson.net</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Just to clarify a little.<br>
If you implement the IO monad in a sane way (as some kind of state<br>
monad or continuation monad) then the compiler can optimize e&gt;&gt;=f even<br>
for the IO monad. &nbsp;The implementation of &gt;&gt;= will ensure the<br>
sequencing of effects in e before effects in f.</blockquote><div><br>I think this answers one of my questions about the relation of category theory to Haskell. Bind is an implementation of the Kleisli star, but the latter, being abstract, may encode data dependency but not sequence.&nbsp; The IO implementation of &gt;&gt;= must ensure sequence, regardless of data dependency (e.g. even for putChar &#39;a&#39; &gt;&gt;= \x -&gt; putChar &#39;c&#39;).&nbsp; <br>
<br>So if we wanted to write a Haskell specification with more formality and detail than the Report, we could say that the IO monad must implement the Kleisli star operator, but that would not be enough, we would also have to require that the implementation ensure sequencing.&nbsp; IOW, Kleisli star implementation plus a constraint on the implementation.&nbsp; Does that sound right?<br>
</div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><br>
The IO monad is less magic than you seem to think it is. :)<br>
</blockquote><div><br></div></div>Any sufficiently advanced technology is isomorphic to magic.&nbsp; ;)<br><br>(<a href="http://www.quotationspage.com/quote/776.html">http://www.quotationspage.com/quote/776.html</a>)<br><br>-gregg<br>