[Haskell-cafe] MonadTrans lift implementation

Daryoush Mehrtash dmehrtash at gmail.com
Mon Jan 19 16:03:55 EST 2009

Is there a reason why the lift function in ReaderT's MonadTrans
instance is implemented as:

instance MonadTrans (ReaderT r) where
    lift m = ReaderT $ \_ -> m

Instead of just using the monad's return function?     Could  "lift m"
be implemented as "return m"?

instance (Monad m) => Monad (ReaderT r m) where
   * return a = ReaderT $ \_ -> return a*
    m >>= k  = ReaderT $ \r -> do
        a <- runReaderT m r
        runReaderT (k a) r
    fail msg = ReaderT $ \_ -> fail msg


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090119/0604814b/attachment.htm

More information about the Haskell-Cafe mailing list