Closed josephcsible closed 1 year ago
The problem with non-empty is that usually this is used on strings, and making a string explicitly a non-empty is a bit of a pain. The problem with giving it a sensible behavior is that it might surprise people. Looking at other languages:
So I guess the behavior you describe makes sense, and I'd be fine with changing it to never error and do the intersperse.
Actually, I'll do it.
Released as 1.7.13
Thanks!
https://github.com/ndmitchell/extra/blob/45249bdff87dad47a8e52bfa3fa90c75bc447917/src/Data/List/Extra.hs#L560
I don't really like that this function is partial. Two ideas on what we could do about it:
Eq a => NonEmpty a -> [a] -> [a] -> [a]
and deprecate this one in favor of itreplace "" "x" "123"
would be"x1x2x3x"
):Do you like either of these ideas?