Haskell platform proposal: split package
byorgey at seas.upenn.edu
Sat Jul 21 14:20:35 CEST 2012
On Sat, Jul 21, 2012 at 09:34:13AM +0200, Henning Thielemann wrote:
> On Fri, 20 Jul 2012, Brent Yorgey wrote:
> >As to whether there is a way to do this without using
> >ExistentialQuantification, I don't see an obvious solution (though
> >there probably is one). The issue is that we certainly don't want to
> >require an (Eq a) constraint when using a predicate, but we need one
> >when matching sublists. I'm open to suggestions.
> If you do not embed the Eq dictionary into DelimSublist then you have
> to add the Eq constraint to some functions. Is this a problem? In
> turn you would get a perfectly portable Haskell 98 module.
No, I do not want to do this. The reason is that you would no longer
be able to do splitting over lists of elements with no Eq instance,
even if you are using a predicate. For example, it is currently
possible to do
fs = [(+1), (subtract 7), (*6)]
fs' = splitWhen (\f -> f 7 == 0) fs
but this would be no longer possible with your patch. This is an
admittedly contrived example, but on principle I don't want to
unnecessarily restrict the API in this way.
More information about the Libraries