Prelude function suggestions

Simon Marlow simonmar at
Wed Jul 28 05:16:48 EDT 2004

On 27 July 2004 23:44, ariep at wrote:

>> {- | Split the list at the occurrences of a separator into sub-list.
>>      This is a generalization of 'words'. -}
>> chop :: (a -> Bool) -> [a] -> [[a]]
>> chop p s =
>>    let (l, s') = break p s
>>    in  l : case s' of
>>            [] -> []
>>            (_:rest) -> chop p rest
> I like 'chop'. It belongs in Data.List, I'd say.

We have something very like this inside GHC, except we call it 'split'.
It's very useful for splitting up file paths into components.

For comparison, Perl calls it 'split'.  In Perl, 'chop' does something
different.  Python also has a 'split' function that does something

Does anyone object to calling it 'split'?


More information about the Libraries mailing list