Henning Thielemann | 16 Dec 19:30 2012
Picon

transformers: instance MonadTrans Compose


What about this instance:

module Data.Functor.Compose

import Control.Monad.Trans.Class (MonadTrans, lift)

instance (Monad f) => MonadTrans (Compose f) where
     lift x = Compose (return x)

?

The constraint (Monad f) is ugly. An (Applicative f) may not fit to a 
*Monad*Trans class. On the other hand, Compose is more oftenly used to 
compose Applicative functors.
Ross Paterson | 16 Dec 21:22 2012
Picon

Re: transformers: instance MonadTrans Compose

On Sun, Dec 16, 2012 at 06:30:45PM +0000, Henning Thielemann wrote:
> What about this instance:
> 
> module Data.Functor.Compose
> 
> import Control.Monad.Trans.Class (MonadTrans, lift)
> 
> instance (Monad f) => MonadTrans (Compose f) where
>      lift x = Compose (return x)
> 
> ?

MonadTrans suggests that the constructed thing is a monad
(though I see the documentation doesn't quite say that).

Gmane