transformers: instance MonadTrans Compose

16 Dec
2012
16 Dec
'12
1:30 p.m.
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.

16 Dec
16 Dec
3:22 p.m.
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).
4538
Age (days ago)
4538
Last active (days ago)
1 comments
2 participants
participants (2)
-
Henning Thielemann
-
Ross Paterson