[Haskell-cafe] Please add a method for optimized concat to the Semigroup class

Stephen Tetley stephen.tetley at gmail.com
Tue May 3 17:24:01 CEST 2011


On 3 May 2011 13:26, Yitzchak Gale <gale at sefer.org> wrote:

>> Both are "kind of, sort of" bringing you up to a Monoid though...
>
> altconcat and sconcatMaybe are doing that, because you
> need to decide what to do with an empty list when you
> define the instance. Holger's interface is not doing that,
> because the type does not require you to say anything
> about the case of an empty list in the instance.

Holger's interface is bringing you "kind of, sort of" up to a Monoid
but it allows neutral of whatever value you fancy at the time.

At which point, either you're working at directly at a type - so you
don't really need the "idea" of a semigroup just its pretty (<>)
operator, or you do actually have a neutral and thus were working with
a Monoid all along - again you just wanted the pretty (<>) operator.

My real contention is that Semigroup doesn't have a proper concat
operation[*], though notationally it is seductive - I do use both
altconcat and Holger's version in my own code.


[*] I could be persuaded otherwise, but I can't see how it would be an
analogue mconcat in Monoid.



More information about the Haskell-Cafe mailing list