<div class="gmail_quote">On Thu, Feb 5, 2009 at 9:27 AM, Bulat Ziganshin <span dir="ltr">&lt;<a href="mailto:bulat.ziganshin@gmail.com">bulat.ziganshin@gmail.com</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;">
Hello Gregg,<br>
<div class="Ih2E3d"><br>
Thursday, February 5, 2009, 6:20:06 PM, you wrote:<br>
<br>
&gt; An optimizer can see that the result of the first getChar is<br>
&gt; discarded and replace the entire expression with one getChar without<br>
&gt; changing the formal semantics.&nbsp;<br>
<br>
</div>this is prohibited by using pseudo-value of type RealWorld which is<br>
passed through entire action stream. actually, order of execution is<br>
controlled by dependencies on this values<br>
<br>
<a href="http://haskell.org/haskellwiki/IO_inside" target="_blank">http://haskell.org/haskellwiki/IO_inside</a><br>
<font color="#888888"><br>
</font></blockquote></div>Thanks.&nbsp; I actually read that a few weeks ago and forgot all about it.&nbsp; So the gist is that type IO has special magic semantics.&nbsp; Formal, but hidden.&nbsp; Which means monad semantics are built in to the language, at least for that type.&nbsp; The Haskell Report doesn&#39;t seem to say anything about this, which seems odd.&nbsp; <br>
<br>But then for non-IO monads, the optimization would be allowed, no?&nbsp; Of course; only the IO monad has external world behavior.<br><br>Thanks,<br><br>gregg<br>