I'm using the following code in some of my projects:
newtype MonadPlusAsMonoid a = MPM { unMPM :: a }
instance MonadPlus m => Monoid (MonadPlusAsMonoid (m a)) where
mempty = MPM mzero
MPM l `mappend` MPM r = MPM (l `mplus` r)
Is there some sort of pitfall I'm not considering?
It seems fine to me, but I ask because I couldn't find this instance
in the darcs repo for the next base library package. I expected to
find it there because it has similar instances for numbers as monoids
(e.g. Sum and Product from Data.Monoid).
Thanks,
Nick
_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe