[Haskell-cafe] IO is not a monad

Duncan Coutts duncan.coutts at worc.ox.ac.uk
Tue Jan 23 06:55:52 EST 2007


On Tue, 2007-01-23 at 13:35 +0200, Yitzchak Gale wrote:
> <troll>
> 
> Prelude> let f .! g = ((.) $! f) $! g
> Prelude> let f = undefined :: Int -> IO Int
> Prelude> f `seq` 42
> *** Exception: Prelude.undefined
> Prelude> ((>>= f) . return) `seq` 42
> 42
> Prelude> ((>>= f) .! return) `seq` 42
> 42
> 
> </troll>

Perhaps I'm missing something but I don't see what's wrong.

I think what you're saying is that you want (>>=) to be strict in it's
second argument. I don't see that this is a requirement of the monad
laws.

You'll note that you get the same behaviour for other monads like Maybe
and [].

I recall that there is some infidelity in standard implementations of
the IO monad, but I don't think this is it.

Duncan



More information about the Haskell-Cafe mailing list