transformers problem: Could not deduce MonadTrans (StateT s) ??

Why this function doesn't compile? phi :: Monad m => StateT s m () phi = lift $ return () I get (ghc-7.4.1) Could not deduce (MonadTrans (StateT s)) arising from a use of `lift' from the context (Monad m) bound by the type signature for phi :: Monad m => StateT s m () at FSMt.hs:28:1-22 Possible fix: add (MonadTrans (StateT s)) to the context of the type signature for phi :: Monad m => StateT s m () or add an instance declaration for (MonadTrans (StateT s)) In the expression: lift In the expression: lift $ return () In an equation for `phi': phi = lift $ return () Failed, modules loaded: none. Anton

On Sat, Jun 23, 2012 at 12:22 PM, Anton Kholomiov wrote: Why this function doesn't compile? phi :: Monad m => StateT s m ()
phi = lift $ return () I get (ghc-7.4.1) Could not deduce (MonadTrans (StateT s))
arising from a use of `lift'
from the context (Monad m) This means exactly what it says: you have stated that m must be a Monad,
but you didn't say anything about whether it's a MonadTrans, so you can't
use "lift". The correct signature would be
phi :: (Monad m, MonadTrans m) => StateT s m ()
--
brandon s allbery allbery.b@gmail.com
wandering unix systems administrator (available) (412) 475-9364 vm/sms
participants (2)
-
Anton Kholomiov
-
Brandon Allbery