[Haskell-cafe] transformers problem: Could not deduce MonadTrans (StateT s) ??

Brandon Allbery allbery.b at gmail.com
Sat Jun 23 19:12:17 CEST 2012

On Sat, Jun 23, 2012 at 12:22 PM, Anton Kholomiov <anton.kholomiov at gmail.com
> 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 at gmail.com
wandering unix systems administrator (available)     (412) 475-9364 vm/sms
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20120623/e733eca9/attachment.htm>

More information about the Haskell-Cafe mailing list