Sorry for sending this twice; I didn't reply to the list initially.

I thought people [1] were generally talking about lift from
Control.Monad.Trans:

class MonadTrans t where
    lift :: Monad m => m a -> t m a

The idea being that lifting through a monad stack feels tedious. The
proposed solution is to use instances to do the lifting for you, like in
mtl. So we've got instances like:

MonadState s m => MonadState s (ReaderT r m)

Which let you automatically lift get/put/modify up a stack, without doing
any work.

This is different from liftM*, which are about applying a pure function
to monadic arguments. This can be done quite nicely with (<$>) and (<*>)
from Data.Functor and Control.Applicative, respectively. Your first
example can be written:


(+) <$> (Just 42) <*> Nothing


Nick

[1]
http://blog.ezyang.com/2013/09/if-youre-using-lift-youre-doing-it-wrong-probably/

Attachment: signature.asc
Description: OpenPGP digital signature

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

Reply via email to