Adding split/split' to Data.List, and redefining words/lines with it; also, adding replace/replaceBy

Henning Thielemann lemming at henning-thielemann.de
Fri Jul 11 06:47:40 EDT 2008


On Fri, 11 Jul 2008, Neil Mitchell wrote:

> Hi
>
>>  ByteString split:
>>
>>>  split 'a'  "aXaXaXa"    == ["","X","X","X",""]
>>
>>
>> Neil's:
>>
>>>  split' 'a'  "aXaXaXa" == ["","X","X","X"]
>>
>>
>> I prefer the ByteString split (i.e. I prefer separator semantics over
>>  terminator), also because it's invertible. Some more support:
>>   http://www.haskell.org/pipermail/haskell-cafe/2006-July/016649.html
>
> I prefer the ByteString split as well! That should be the one we use.

A minor issue is, that 'split' does always return a non-empty list, which 
is not expressed by the list type of the result, but it would be nicely 
expressed by the alternating list type. In some cases it is necessary to 
handle the first or the last element differently, which requires that 
there is a first or a last element.


More information about the Libraries mailing list