<div class="gmail_quote">On Thu, Feb 5, 2009 at 9:27 AM, Bulat Ziganshin <span dir="ltr"><<a href="mailto:bulat.ziganshin@gmail.com">bulat.ziganshin@gmail.com</a>></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>
> An optimizer can see that the result of the first getChar is<br>
> discarded and replace the entire expression with one getChar without<br>
> changing the formal semantics. <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. I actually read that a few weeks ago and forgot all about it. So the gist is that type IO has special magic semantics. Formal, but hidden. Which means monad semantics are built in to the language, at least for that type. The Haskell Report doesn't seem to say anything about this, which seems odd. <br>
<br>But then for non-IO monads, the optimization would be allowed, no? Of course; only the IO monad has external world behavior.<br><br>Thanks,<br><br>gregg<br>