[Haskell-cafe] Does somebody know about these functions?

Johan Holmquist holmisen at gmail.com
Thu Mar 1 21:28:00 CET 2012

So, these two functions do not appear to be defined, perhaps because
many of their potential uses could be expressed using the functions
from Data.Applicative and Data.Arrow instead.

You may have noticed that the words and lines examples where defunct,
but not difficult to fix:

words = go . dropWhile isSpace where
    go [] = []
    go s  = withPair (:) id words (break isSpace s)

lines [] = []
lines s  = withPair (:) id (lines . safeTail) (break (== '\n') s)

safeTail [] = []
safeTail l  = tail l

Ofcourse RHS of 'lines s' can be written (and likewise for words):

uncurry (:) $ second (lines . safeTail) $ break (== '\n') s

which looks rather nice to me.


More information about the Haskell-Cafe mailing list