
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

Of course I find it two minutes after I send the question.
Sorry for the two noop emails.
Nick
On 8/30/06, Nicolas Frisby
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
participants (1)
-
Nicolas Frisby