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