:: ([a] -> (b, [a])) -> [a] -> [b]

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)
Apply some operation repeatedly, producing an element of output and the remainder of the list. When the empty list is reached it is returned, so the operation is never applied to the empty input. That fact is encoded in the type system with repeatedlyNE
\xs -> repeatedly (splitAt 3) xs  == chunksOf 3 xs
\xs -> repeatedly word1 (trim xs) == words xs
\xs -> repeatedly line1 xs == lines xs
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)