Hi Wolfgang,

I don't know the history so maybe this is a new implementation of
State transformer. The Peek and poke functions are defined below
(copied from StateT.hs):

instance Monad m => StateM (StateT s m) s where
  peek              = S (\s -> return (s,s))
  poke s            = S (\s1 -> return (s1,s))

The question is why can't the mplus be written as simple as what
Andrew suggested:

    mplus m1 m2 = S (\s ->  let m1' = runState s m1
                               m2' = runState s m2
                           in  ~(a, s') <- mplus m1' m2'
                               return (a, s'))

this is easier to understand. I don't see what's the purpose of the
peek, lift, poke, return in the new implementattion.

Cheers,
Fan
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to