lines/unlines and "inverse"

Ian Lynagh igloo@earth.li
Sat, 20 Jul 2002 15:03:22 +0100


Just above
http://research.microsoft.com/Users/simonpj/haskell98-revised/haskell98-report-html/standard-prelude.html#$vlines
it says

-- lines breaks a string up into a list of strings at newline
-- characters. The resulting strings do not contain newlines.
-- Similary, words breaks a string up into a list of words, which
-- were delimited by white space.  unlines and unwords are the
-- inverse operations. unlines joins lines with terminating
-- newlines, and unwords joins words with separating spaces.

I think the use of "inverse" is potentially confusing given,
well, they aren't inverses (or even left or right inverses).

e.g.

unwords (words " ") == ""
words (unwords [""]) == []
unlines (lines " ") == " \n"
lines (unlines ["\n"]) == ["",""]


Thanks
Ian, who thinks (unlines . lines == id) would have been useful. Oh well.