Proposal: Add split and splitWith (trac #2048)

Christian Maeder Christian.Maeder at dfki.de
Thu Jan 17 10:51:47 EST 2008


Christian Maeder wrote:
> Don Stewart wrote:
>> Note here the funniness of lines, complicates the properties:

[...]

> Data.ByteString.Char8.split only behaves differently to the proposed
> Data.List.split function on empty input lists. (as Twan showed)
> 
>   last xs == '\n' ==>
>     lines xs == Data.List.split '\n' (init xs)

This property would be wrong for Data.ByteString.Char8.split and "\n".

If we ignore the empty input (which is trivial) the following remaining
property case is:

    not (null xs) && last xs /= '\n' ==>
      Data.List.split '\n' xs = lines (xs ++ "\n")

which is true also for Data.ByteString.Char8.split

Christian


More information about the Libraries mailing list