Proposal: Add split and splitWith (trac #2048)

Christian Maeder Christian.Maeder at dfki.de
Thu Jan 17 10:31:40 EST 2008


Don Stewart wrote:
> Note here the funniness of lines, complicates the properties:
> 
>     prop_linessplit xs =
>         lines xs == split '\n' xs ++ (if last xs == '\n' then [empty] else [])

This property is wrong (i.e. for xs == "\n")

> What properties relating to current List functoins does this split have?

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)

Christian


More information about the Libraries mailing list