[Haskell-beginners] Lazy state + IO not lazy?

Jan Snajder jan.snajder at fer.hr
Sun Oct 26 21:34:44 UTC 2014


Dear Haskellers,

I'm confused with the behaviour of a lazy state monad when combined with
an IO monad. Look at this:

ghci> Control.Monad.State.Lazy.evalState (head `fmap` mapM return
(1:undefined)) 0
1

ghci> Control.Monad.State.Lazy.evalStateT (head `fmap` mapM return
(1:undefined)) 0
*** Exception: Prelude.undefined

I would have expected the second case to behave identically to the first
case. Why is this not the case?

Cheers,
Jan


More information about the Beginners mailing list