Commit fa61edde authored by glguy's avatar glguy Committed by Ben Gamari

Improve documentation of Data.List.lines:

- Document behavior on some inputs.
- Add some examples.

Reviewers: bgamari, osa1, hvr, dolio, #core_libraries_committee,
nomeata, austin

Reviewed By: bgamari, dolio, #core_libraries_committee, nomeata, austin

Subscribers: dolio, glguy, nomeata, thomie

Differential Revision: https://phabricator.haskell.org/D1450
parent 109d7ce8
...@@ -1044,6 +1044,20 @@ unfoldr f b0 = build (\c n -> ...@@ -1044,6 +1044,20 @@ unfoldr f b0 = build (\c n ->
-- | 'lines' breaks a string up into a list of strings at newline -- | 'lines' breaks a string up into a list of strings at newline
-- characters. The resulting strings do not contain newlines. -- characters. The resulting strings do not contain newlines.
--
-- Note that after splitting the string at newline characters, the
-- last part of the string is considered a line even if it doesn't end
-- with a newline. For example,
--
-- > lines "" == []
-- > lines "\n" == [""]
-- > lines "one" == ["one"]
-- > lines "one\n" == ["one"]
-- > lines "one\n\n" == ["one",""]
-- > lines "one\ntwo" == ["one","two"]
-- > lines "one\ntwo\n" == ["one","two"]
--
-- Thus @'lines' s@ contains at least as many elements as newlines in @s@.
lines :: String -> [String] lines :: String -> [String]
lines "" = [] lines "" = []
-- Somehow GHC doesn't detect the selector thunks in the below code, -- Somehow GHC doesn't detect the selector thunks in the below code,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment