
24 Jun
2013
24 Jun
'13
3:07 p.m.
On Mon, Jun 24, 2013 at 2:53 PM, Dan Burton
I also agree with Henning.
If anything, the 1st instance could be a ContT instance for Monoid.
instance (Monoid r, Monad m) => Monoid (ContT r m a) where mempty = ContT $ const $ return mempty m `mappend` n = ContT $ \ c -> liftM2 mappend (runContT m c) (runContT n c)
That way both behaviors are easily accessible. Is there any other sensible ContT instance for Monoid?
Yes. The third construction is the 'universal' lifting that works for every Applicative, which would look like: instance (Monad m, Monoid a) => Monoid (ContT r m a) where mempty = return mempty mappend = liftM2 mappend -Edward