On Thu, Feb 5, 2009 at 9:53 AM, Gleb Alexeyev <[email protected]>wrote:
> Let's imagine that IO datatype is defined thus:
>
> >{-# LANGUAGE GADTs #-}
> >{-# LANGUAGE NoImplicitPrelude #-}
>
> >import Prelude(Monad, Char)
> >data IO a where
> > GetChar :: IO Char
> > Bind :: IO a -> (a -> IO b) -> IO b
>
> >getChar = GetChar
> >(>>=) = Bind
>
> 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
> getChar >>= \x -> getChar would be optimized to getChar by compiler?
>
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?
-g
_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe