[Haskell-cafe] Re: monadplus as monoid, safe?

Nicolas Frisby nicolas.frisby at gmail.com
Wed Aug 30 15:59:54 EDT 2006

Of course I find it two minutes after I send the question.

Sorry for the two noop emails.


On 8/30/06, Nicolas Frisby <nicolas.frisby at gmail.com> wrote:
> 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

More information about the Haskell-Cafe mailing list