Cont as Monoid
conal at conal.net
Sun Sep 9 00:42:56 EDT 2007
Hm. I hadn't considered the liftM2 version. It would need Monoid a instead
of Monoid r, and it would behave differently. The version I suggested is
motivated by a library for a Fran-like functional event-based programming
that I'm preparing to release, based on Cont. In the monoid def I gave
corresponds, mempty is the never-occurring event, and mappend is a sort of
union of two events.
I sure don't know how to resolve these situations of more than one credible
instance. I'm seeing more & more of them.
Thanks for the pointer on library submissions.
I'm with you about liftM0 (and liftA0).
Cheers, - Conal
On 9/8/07, Stefan O'Rear <stefanor at cox.net> wrote:
> On Sat, Sep 08, 2007 at 05:26:09PM -0700, Conal Elliott wrote:
> > I'd like to see the following addition to Control.Monad.Cont in mtl:
> > instance Monoid r => Monoid (Cont r a) where
> > mempty = Cont mempty
> > m `mappend` m' = Cont (runCont m `mappend` runCont m')
> > What's the process for suggesting, discussing, and making such changes?
> (My 2 cents: Why not mempty = return mempty; mappend = liftM2 mappend ?
> Instances are best if unambiguous.)
> (Why is there no liftM0 ?)
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.6 (GNU/Linux)
> -----END PGP SIGNATURE-----
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Libraries