[Haskell-cafe] Execution order in IO

silvio silvio.frischi at gmail.com
Wed Apr 15 16:44:47 UTC 2015


> Note that these do not correspond to the Strict and Lazy State in
> transformers. The former (which you call lazy) corresponds to Strict
> from transformers. The lazier version uses lazy pattern matching in
> bind.

I knew I was going to make a mistake somewhere :). The problem is they
are transformers and i wanted an example without transformers to confuse
the issue


So what would be a correct lazy version??

instance Monad (State s) where
    act1 >>= f2 = State $ \s1 -> runState (f2 (fst res)) (snd res) where
        res = runState act1 s1

instance Monad (State s) where
    act1 >>= f2 = State $ \s1 -> runState (f2 input2) s2 where
        ~(input2, s2) = runState act1 s1

These should do the same right?

Silvio


More information about the Haskell-Cafe mailing list