Re: [Haskell-cafe] Please add instance Semigroup Text

2011-05-03 Thread Antoine Latter
On Tue, May 3, 2011 at 3:14 PM, Yitzchak Gale  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@haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Please add instance Semigroup Text

2011-05-03 Thread Don Stewart
Getting stuff into the HP is a different problem, and something I'm
working on addressing in coming weeks... stay tuned.

On Tue, May 3, 2011 at 2:33 PM, Bryan O'Sullivan  wrote:
> On Tue, May 3, 2011 at 1:14 PM, Yitzchak Gale  wrote:
>>
>> 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.
>
> Unfortunately, the semigroups package will have to go into the Platform
> before either text or bytestring can make use of it. I think that would be
> great to have, but the getting from here to there is not necessarily fun.
> ___
> Haskell-Cafe mailing list
> Haskell-Cafe@haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
>

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Please add instance Semigroup Text

2011-05-03 Thread Bryan O'Sullivan
On Tue, May 3, 2011 at 1:14 PM, Yitzchak Gale  wrote:

> 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.


Unfortunately, the semigroups package will have to go into the Platform
before either text or bytestring can make use of it. I think that would be
great to have, but the getting from here to there is not necessarily fun.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Please add instance Semigroup Text

2011-05-03 Thread Yitzchak Gale
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.

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@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Please add instance Semigroup Text

2011-05-03 Thread Edward Kmett
On Tue, May 3, 2011 at 12:04 PM, Bryan O'Sullivan wrote:

> On Tue, May 3, 2011 at 8:00 AM, Yitzchak Gale  wrote:
>
>>
>> Could you please add a Semigroup instance for Text?
>>
>
>
I'd strongly recommend writing an instance for the text package's Builder
> type instead. Vastly more efficient for non-trivial jobs.
>

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 in contrast to my previous efforts. In
fact, I'll likely invert the dependencies from tagged and void, leaving only
the dependency on containers, which is somewhat unavoidable, but still
Haskell 98.

My goal was to build a very small standardizable library.

Data.Text requires dependencies that would take my package and a whole
hierarchy of other Haskell 98 packages that are built on top of it, out of
Haskell 98.

-Edward


>
>
>> Once you're doing that, I suppose you'd also want to
>> add it for lazy Text and both kinds of ByteStrings.
>>
>
> Likewise, there's allegedly work afoot to write a builder for bytestrings.
>
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Please add instance Semigroup Text

2011-05-03 Thread Bryan O'Sullivan
On Tue, May 3, 2011 at 8:00 AM, Yitzchak Gale  wrote:

>
> Could you please add a Semigroup instance for Text?
>

I'd strongly recommend writing an instance for the text package's Builder
type instead. Vastly more efficient for non-trivial jobs.


> Once you're doing that, I suppose you'd also want to
> add it for lazy Text and both kinds of ByteStrings.
>

Likewise, there's allegedly work afoot to write a builder for bytestrings.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Please add instance Semigroup Text

2011-05-03 Thread Yitzchak Gale
Hi Edward,

Could you please add a Semigroup instance for Text?

Once you're doing that, I suppose you'd also want to
add it for lazy Text and both kinds of ByteStrings.
But what I currently need is strict Text.

The reason, of course, is that in complex calculations <>
is *so* much more readable than `mappend`. Obviously
WrappedMonoid is useless there.

Hmm, and now for Semigroup and Monoid we start down
the same path as for Functor and Monad...

Or should we give <> back to Monoid and use something
different for Semigroup? That doesn't seem very nice
either...

Well, in the meantime, you really will make my life easier
if you could add some more Semigroup instances
for popular Monoids.

Thanks,
Yitz

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe