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

Edward Kmett ekmett at gmail.com
Sun Aug 14 22:15:45 CEST 2011


On Sun, Aug 14, 2011 at 12:44 PM, Yitzchak Gale <gale at sefer.org> wrote:

> Malcolm Wallace wrote:
> > For instance, although I can guess at "sconcat", what semantics is
> "replicate1p" supposed to have?
>

A semigroup is just an associative operator.

sconcat is analogous to mconcat, providing a potentially optimized traversal
over a non-empty list. Not necessarily in theory, but in practice quite
useful.

replicate1p needs to be renamed, but it repeats an element (n + 1) times
using peasant multiplication, taking advantage of the associativity to get
away with using (<>) only log n times.

replicate1p 0 a = a
replicate1p 1 a = a <> a
replicate1p 3 a = (a <> a) <> (a <> a)

etc.

I am happy to spend some time working on the documentation.

-Edward
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/libraries/attachments/20110814/a9e1bab3/attachment.htm>


More information about the Libraries mailing list