Haskell platform proposal: split package

Brent Yorgey byorgey at seas.upenn.edu
Sat Jul 21 15:18:49 CEST 2012


On Sat, Jul 21, 2012 at 02:59:45PM +0200, Twan van Laarhoven wrote:
> On 2012-07-21 14:30, Twan van Laarhoven wrote:
> >Would the following type work?
> >
> >data Delimiter a = DelimEltPred (a -> Bool) | DelimSublistPred [a -> Bool]
> >
> >You can go from the current DelimSublist to DelimSublistPred with just `map
> >(==)`. And is the distinction between the DelimEltPred and DelimSublistPred
> >then still needed at all?
> 
> I attached some code that uses the simplified Delimiter type.

Brilliant!  Yes, this is a big improvement, and does indeed allow
getting rid of the ExistentialQuantification (or GADTs) extension.  I
will make this change for sure, regardless of the outcome of the
review process.

> As an aside, the documentation for splitPlaces contains this unhelpful remark:
> 
> >The behavior of splitPlaces ls xs when sum ls /= length xs can be inferred
> >from the above examples and the fact that splitPlaces is total.
> 
> To me that reads like "the documentation of this function is left as
> an exercise to the reader". Perhaps say something like:
> 
>     If the input list is longer than the total of the given lengths,
> then the remaining elements are dropped. If the list is shorter than
> the total of the given lengths, then the result may contain fewer
> chunks, and the last chunk may be shorter.
> 
> While `splitPlacesBlanks` could say something like:
> 
>     If the input list is longer than the total of the given lengths,
> then the remaining elements are dropped. If the list is shorter than
> the total of the given lengths, then the last several chunk will be
> shorter or empty.

Ah, yes, I agree.  I must have been in somewhat of a cheeky mood when
I wrote that.  I will improve the documentation, thanks for the
suggestions.

-Brent



More information about the Libraries mailing list