[Haskell-cafe] wordsBy in the base libraries?

Maxime Henrion mux at FreeBSD.org
Mon Oct 22 06:17:46 EDT 2007

Jules Bean wrote:
> Maxime Henrion wrote:
> >	Hello all,
> >
> >
> >What do you think about having a wordsBy function in the standard
> >libraries?  It often comes in handy.
> I speculate (but don't know) that the reason we don't have one is that 
> there are quite a few choices to make:
> * delimiter as function (Char -> Bool) or Char
> * delimit by single chars only or multiple (String -> Bool)
> * multiple adjacent delimiters cause empty items, or not?
> * exact delimiter which occured returned as part of the result?
> ... my anecdotal experience is that in practice for slightly different 
> applications you need different permutations of these choices. A single 
> function which encompassed all the options would have a cumbersome type.

I fully agree with you in that we often need slight variations of such a
function, and that writing one that encompasses all different uses would
probably be less convenient to use.  However, we could argue just the
same about the "words" function.  Since it's there, and that it's going
to stay, I still find the "wordsBy" function nice to have in the
standard libraries.  Besides, it seems to me we often need that
particular behaviour of words (single character matches, "eating" empty


More information about the Haskell-Cafe mailing list