[Haskell-cafe] Please add a method for optimized concat to the Semigroup class
holgersiegel74 at yahoo.de
Tue May 3 13:56:08 CEST 2011
Am 03.05.2011 um 13:39 schrieb Stephen Tetley:
> Does it have an obvious default implementation, bearing in mind it we
> might really want a total function?
> sconcat  = error "Yikes - I wish this was total!"
> sconcat [a] = a
> sconcat (a:as) = a <> sconcat as
You have to provide the "neutral" element by yourself:
infixl 4 <>>
a <>>  = a
a <>> (b:bs) = a <> b <>> bs
> Best wishes
> On 3 May 2011 12:12, Yitzchak Gale <gale at sefer.org> wrote:
>> It has the obvious default implementation,
>> but allows for an optimized implementation for
>> specific instances. That turns out to be something
>> that comes up all the time (at least for me) in
>> real life.
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
More information about the Haskell-Cafe