[Haskell-cafe] Missing join and split

Benja Fallenstein benja.fallenstein at gmail.com
Fri Dec 28 10:33:19 EST 2007


On Dec 28, 2007 4:24 PM, Benja Fallenstein <benja.fallenstein at gmail.com> wrote:
> Right; I misspoke. What I meant was that you would want a split such that
>
>     intercalate a (split a xs) = a
>
> for finite, total (a,xs) (and, since it's achievable, even for
> infinite xs). Of course, (split a xs = [xs]) satisfies that, but if we
> add the requirement that split is also supposed to do its job :-) then
> I think split is fully specified except for whether (split a [] = [])
> or (split a [] = [[]]).

I take that back; it doesn't specify whether (split "xx" "xxx") should
be ["","x"] or ["x",""]. I prefer the former, because working
left-to-right seems natural, and because it makes split more lazy (it
can yield ("":_) before evaluating the input enough to see the third
'x').

> The latter seems better to me; e.g., it
> satisfies
>
>     split a (x ++ a ++ y) = split a x ++ split a y

I take that back, too:

split "xx" "xxxx" = ["","",""]
split "xx" "x" ++ split "xx" "xxx" = ["x"] ++ ["","x"]

("...but, still..." :-))

- Benja


More information about the Haskell-Cafe mailing list