
15 Jun
2011
15 Jun
'11
8:58 a.m.
On Wed, Jun 15, 2011 at 11:36 AM, Simon Peyton-Jones
| 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.