Prelude function suggestions

Christian Maeder maeder at
Wed Jul 28 07:09:34 EDT 2004

> split  isSpace " foo  bar baz " = ["foo","bar","baz"]
> split' isSpace " foo  bar baz " = ["","foo","","bar","baz",""]

split can be obtained from split' via composition with "filter (not . 
null)". Therefore the second version (split') is more important.

The name "chop" confused me in the first place (as I thought only the 
last element should be chopped off)

The name "split" is a bit too general. (compared with "intersperse" that 
  somehow computes the opposite.)

The haddock library docs

1 (Function)	GHC.Exts
2 (Function)	Language.Haskell.THSyntax
3 (Function)	System.Random, Random
splitAt	Data.List, GHC.List, Prelude, List
splitAtPS	Data.PackedString
splitPS	Data.PackedString
splitWithPS	Data.PackedString

According to PackedString the above function split' should be named 
"splitWith" since it has a predicate argument. (So we do not need to 
conform to PackedString.)

Btw "splitWithPS" and "splitPS" are wrong as they ignore a (single) 
final blank!

splitWithPS isSpace $ packString " foo  bar baz "  =

Maybe "splitToLists" or "splitUp" (or "splitUpOn") are better names

More information about the Libraries mailing list