<div class="gmail_quote">On Thu, Feb 5, 2009 at 9:53 AM, Gleb Alexeyev <span dir="ltr">&lt;<a href="mailto:gleb.alexeev@gmail.com">gleb.alexeev@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;">
Let&#39;s imagine that IO datatype is defined thus:<br>
<br>
&gt;{-# LANGUAGE GADTs #-}<br>
&gt;{-# LANGUAGE NoImplicitPrelude #-}<br>
<br>
&gt;import Prelude(Monad, Char)<br>
&gt;data IO a where<br>
&gt; &nbsp; &nbsp;GetChar :: IO Char<br>
&gt; &nbsp; &nbsp;Bind :: IO a -&gt; (a -&gt; IO b) -&gt; IO b<br>
<br>
&gt;getChar = GetChar<br>
&gt;(&gt;&gt;=) = Bind<br>
<br>
It is perfectly possible to construct IO actions as values of this data type and execute them by some function evalIO :: IO -&gt; Prelude.IO with the obvious definition. Now the question arises: do you think<br>
getChar &gt;&gt;= \x -&gt; getChar would be optimized to getChar by compiler?<br>
</blockquote><div><br>I must be misunderstanding something.&nbsp; I don&#39;t know if it would be optimized out, but I see no reason why it couldn&#39;t be.&nbsp; There&#39;s no data dependency, right?<br></div></div><br>-g<br>