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

Thomas Schilling nominolo at googlemail.com
Sun Nov 6 22:44:16 CET 2011


On 6 November 2011 20:52, Edward Kmett <ekmett at gmail.com> wrote:

> Ultimately no code breaks, after all it is changing the associativity of an
> operator that is by definition associative. ;)

Well, as Duncan pointed out, some code *does* break due to the
interaction of <> and <+>.  HughesPJ pretty has the rule:

   empty <+> d = d

so (using current assocativity)

  (foo <> empty) <+> bar  ==  foo <+> bar

or (using new associativity):

   foo <> (empty <+> bar) == foo <> bar

As Duncan mentioned, that problem occurs in GHC if you change its
pretty printer to use right-assocative <>/<+>.

I think that's a design problem, because the same unintuitive problem
could happen with the current assocativity:

  foo <+> empty <> bar

The better way to avoid this is to make sure <> binds more tightly
than <+>, as proposed in another mail.

/ Thomas



More information about the Libraries mailing list