On Wed, Jun 15, 2011 at 11:36 AM, Simon Peyton-Jones <simo...@microsoft.com> wrote: > | instance (Monad m) => MonadState s (StateT s m) where > | get = StateT $ \s -> return (s, s) > | > | instance (Monad (t m), MonadTrans t, MonadState s m) => > | MonadState s (t m) where > | get = lift get > | put = lift . put > > Why do you need the first instance? Isn't the second sufficient for (StateT > s m) as well? > > Simon >
The second will define /an/ instance for StateT s m, but it'll be the wrong one :) the second instance says 'pass the responsibility for dealing with state to the transformed monad', whereas the StateT wants to deal with the state itself. _______________________________________________ Haskell-prime mailing list Haskell-prime@haskell.org http://www.haskell.org/mailman/listinfo/haskell-prime