([a] -> (b, [a])) -> [a] -> [b] +split +default

chop :: ([a] -> (b, [a])) -> [a] -> [b]
split Data.List.Split.Internals, split Data.List.Split
A useful recursion pattern for processing a list to produce a new list, often used for "chopping" up the input list. Typically chop is called with some function that will consume an initial prefix of the list and produce a value and the rest of the list. For example, many common Prelude functions can be implemented in terms of chop: > group :: (Eq a) => [a] -> [[a]] > group = chop (\ xs@(x:_) -> span (==x) xs) > > words :: String -> [String] > words = filter (not . null) . chop (span (not . isSpace) . dropWhile isSpace)