[Haskell-cafe] Please add instance Semigroup Text

Antoine Latter aslatter at gmail.com
Wed May 4 00:14:35 CEST 2011


On Tue, May 3, 2011 at 3:14 PM, Yitzchak Gale <gale at sefer.org> wrote:
> I wrote:
>>>> Could you please add a Semigroup instance for Text?
>
> Edward Kmett wrote:
>> Unfortunately, I don't think I can really bring myself to do either.
>> I was deliberately trying to keep the number of dependencies for the
>> semigroups as low as possible...
>
> You are quite right. These should really be defined in their
> respective packages. I don't think it's too onerous for them
> to add a dependency on semigroups, even before you
> reverse the few lightweight dependencies that semigroups has.
>
> Bryan O'Sullivan wrote:
>>> I'd strongly recommend writing an instance for the text
>>> package's Builder type instead. Vastly more efficient
>>> for non-trivial jobs.
>
> Well, in my case, I'm iterating over many small Texts, slicing
> and dicing small groups of them in various ways to look for
> overlaps, and splicing the pieces back together in different
> combinations. It's quite fast as it is; what I'm looking for is to
> make the formulas look simpler and more understandable.
> I doubt that builders will be any help for that. Whereas using
> <> from semigroups instead of `T.append` or `mappend`
> is a huge help.

Can you locally define an operator (<>) for monoids?

>
> Apart from my own use case, semigroups are a simple
> and fundamental idiom that I think will become much
> more widely used as people become more aware of them.
> Just like every Monad should have a Functor instance,
> every Monoid should have a Semigroup instance.
>
> Thanks,
> Yitz
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>



More information about the Haskell-Cafe mailing list