Better to drill into the heart of the question and put aside state transformers for now. Consider let u = return () :: IO () in expr >> u where expr ranges over (return undefined), (undefined), and (error "urk"). Are their executions surprising? Compare to let u = return () :: State Int () in evalState (expr >> u) 0 for both strict and lazy state. IO above matches one of them. Suppose IO's behavior matches the other, what happens? Now with the definition of mapM in mind, consider the difference between your original: Lazy.evalStateT (head `fmap` mapM return (1:undefined)) 0 and Lazy.evalStateT (head `fmap` mapM return [1,undefined]) 0 Did you mean the latter? -- Kim-Ee On 10/27/14, Jan Snajder <jan.snajder@fer.hr> wrote:
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 _______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners
-- -- Kim-Ee