
Donald Bruce Stewart schrieb:
No parsers!
I agree,
I vote for this, currently implemented in Data.ByteString:
from which package comes Data.ByteString?
-- | split on characters split :: Char -> String -> [String]
the type for lists should then be: split :: Eq a => a -- ^ seperator -> [a] -- ^ list to split -> [[a]] (as I proposed earlier as "splitOn")
-- | split on predicate * splitBy :: (Char -> Bool) -> String -> [String]
According to Data.PackedString (with splitPS and splitWithPS) the name should be "splitWith" for consistency (or splitWithPS should be renamed as well).
-- | split on a string tokens :: String -> String -> [String]
I don't think, that we need this function for lists.
Question over whether it should be: splitBy (=='a') "aabbaca" == ["","","bb","c",""] or splitBy (=='a') "aabbaca" == ["bb","c"]
I argue the second form is what people usually want.
Yes, the second form is needed for "words", but the first form is needed for "lines", where one final empty element needs to be removed from your version! Prelude> lines "a\nb\n" ["a","b"] Prelude> lines "a\n\nb\n\n" ["a","","b",""] One more question is whether it should be: splitBy (=='a') "aabbaca" == ["","","bb","c",""] or splitBy (=='a') "aabbaca" == ["","","bb","c"] This second form corresponds to splitPS but the first more general form may be desirable as well. Christian