Proposal #3339: Add (+>) as a synonym for mappend

Edward Kmett ekmett at gmail.com
Fri Jul 17 15:57:06 EDT 2009


The main concern with generalizing (++) is that it was once generalized
-- completely differently! -- for mplus in MonadPlus. So whether Monoid's
mappend is the natural generalization of (++) or MonadPlus's mplus is, is
not entirely clear. Neither one can completely subsume all of the use-cases
of the other.

A secondary concern is that neither MonadPlus nor Monoid are in the Prelude,
so its generalized form would have to be exported from Data.Monoid with a
different type signature breaking any pre-existing code that brought in
Data.Monoid unqualified and happened to use lists.

I'm less sold by the second concern than the first one, but both make me
hesitate.

Bryan's/Jules's existing proposal of a new operator avoids both of these
snarls.

-Edward Kmett



On Fri, Jul 17, 2009 at 10:53 AM, Alexander Dunlap <
alexander.dunlap at gmail.com> wrote:

> On Tue, Jun 30, 2009 at 5:37 PM, Bryan O'Sullivan<bos at serpentine.com>
> wrote:
>  > Ticket: http://hackage.haskell.org/trac/ghc/ticket/3339
> >
> > From the ticket:
> >
> > This proposal was, I think, originally suggested by Jules Bean. The idea
> is
> > to add two functions to the Data.Monoid module, (+>) and (<+),
> corresponding
> > to different uses of mappend. These should not be methods of the Monoid
> > typeclass, but top-level functions.
> >
> > I hope (but slightly doubt) that the visual nature of the two operators
> > might help to counter the thought that monoids are just for gluing things
> > together.
> >
> > (+>) :: (Monoid a) => a -> a -> a
> > a +> b = a `mappend` b
> >
> > (<+) :: (Monoid a) => a -> a -> a
> > a <+ b = b `mappend` a
> >
> > infixl 4 +>
> > infixl 4 <+
> >
> > Proposed deadline: two weeks.
> >
> > If this looks reasonable, I'll attach darcs patches.
> >
>
> I (and apparently a lot of other people who commented on that ticket)
> would prefer that (++) be generalized instead of introducing a new
> operator.
>
> Alex
>  _______________________________________________
> Libraries mailing list
> Libraries at haskell.org
> http://www.haskell.org/mailman/listinfo/libraries
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/libraries/attachments/20090717/b80a6980/attachment.html


More information about the Libraries mailing list