lines

Splits the argument into a list of lines stripped of their terminating \n characters. The \n terminator is optional in a final non-empty line of the argument string. When the argument string is empty, or ends in a \n character, it can be recovered by passing the result of lines to the unlines function. Otherwise, unlines appends the missing terminating \n. This makes unlines . lines idempotent:
(unlines . lines) . (unlines . lines) = (unlines . lines)

Examples

>>> lines ""           -- empty input contains no lines
[]
>>> lines "\n"         -- single empty line
[""]
>>> lines "one"        -- single unterminated line
["one"]
>>> lines "one\n"      -- single non-empty line
["one"]
>>> lines "one\n\n"    -- second line is empty
["one",""]
>>> lines "one\ntwo"   -- second line is unterminated
["one","two"]
>>> lines "one\ntwo\n" -- two non-empty lines
["one","two"]
lines breaks a ByteString up into a list of ByteStrings at newline Chars ('\n'). The resulting strings do not contain newlines. Note that it does not regard CR ('\r') as a newline character.
lines lazily splits a ByteString into a list of ByteStrings at newline Chars ('\n'). The resulting strings do not contain newlines. The first chunk of the result is only strict in the first chunk of the input. Note that it does not regard CR ('\r') as a newline character.
O(n) Breaks a Text up into a list of Texts at newline characters '\n' (LF, line feed). The resulting strings do not contain newlines. lines does not treat '\r' (CR, carriage return) as a newline character.
Split a string into a list of lines. Lines are terminated by '\n' or the end of the string. Empty lines may not be terminated by the end of the string. See also lines'.
Split a string into a list of lines. Lines are terminated by '\n' or the end of the string. Empty lines may not be terminated by the end of the string. See also lines'.
Split a string into a list of lines. Lines are terminated by '\n' or the end of the string. Empty lines may not be terminated by the end of the string. See also lines'.
Splits the argument into a list of lines stripped of their terminating \n characters. The \n terminator is optional in a final non-empty line of the argument string. For example:
>>> lines ""           -- empty input contains no lines
[]

>>> lines "\n"         -- single empty line
[""]

>>> lines "one"        -- single unterminated line
["one"]

>>> lines "one\n"      -- single non-empty line
["one"]

>>> lines "one\n\n"    -- second line is empty
["one",""]

>>> lines "one\ntwo"   -- second line is unterminated
["one","two"]

>>> lines "one\ntwo\n" -- two non-empty lines
["one","two"]
When the argument string is empty, or ends in a \n character, it can be recovered by passing the result of lines to the unlines function. Otherwise, unlines appends the missing terminating \n. This makes unlines . lines idempotent:
(unlines . lines) . (unlines . lines) = (unlines . lines)
Split the input bytes into lines. In other words, split on the LF byte (10), and strip it from the output. Since 0.3.0
Emit each line separately Since 0.4.1
Splits a bytestring InputStream into lines. See splitOn and lines. Example:
ghci> is <- Streams.fromList ["Hello,\n world!"] >>= Streams.lines
ghci> replicateM 3 (Streams.read is)
[Just "Hello", Just ", world!", Nothing]
Note that this may increase the chunk size if the input contains extremely long lines.
lines takes Text and splits it into the list by lines. Actual type of this function is the following:
lines :: Text -> [Text]
but it was given a more complex type to provide friendlier compile time errors.
>>> lines ""
[]

>>> lines "one line"
["one line"]

>>> lines "line 1\nline 2"
["line 1","line 2"]

>>> lines ("string line" :: String)
...
... 'lines' works with 'Text', not 'String'.
Possible fixes:
1. Make sure OverloadedStrings extension is enabled.
2. Apply 'toText' to a single value.
3. Apply 'map toText' to the list value.
...

>>> lines True
...
... 'lines' works with 'Text'
But given: 'Bool'
...
lines breaks a string up into a list of strings at newline 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.
O(n) Breaks a Text up into a list of Texts at newline Chars. The resulting strings do not contain newlines.
Break up a textual sequence at newline characters.
> lines "hello\nworld"
["hello","world"]
Improper lens between a bytestream and its lines Note: This function is purely for demonstration purposes since it assumes a particular encoding. You should prefer the Text equivalent of this function from the pipes-text library.
lines turns a ByteStream into a connected stream of ByteStreams at divide at newline characters. The resulting strings do not contain newlines. This is the genuinely streaming lines which only breaks chunks, and thus never increases the use of memory. Because ByteStreams are usually read in binary mode, with no line ending conversion, this function recognizes both \n and \r\n endings (regardless of the current platform).
Breaks a string into a list of strings
O(n) Breaks a JSString up into a list of JSStrings at newline Chars. The resulting strings do not contain newlines.
This is like lines' but it does *not* preserve newlines. Specifically, we just strip the newlines from the result of lines'. This behaves slightly differently than the old split: the number of resulting strings here is equal to the number of newline characters in the underlying string. This is much more consistent than the old behaviour which blindly used ByteStrings split and stitched the result back together which was inconsistent with the rest of the interface which worked with number of newlines.
The lines function breaks a stream of characters into a list of strings at newline characters. The resulting strings do not contain newlines. Beware: if the stream of characters xs does not contain newline characters, accessing the tail of lines xs will loop.
Break a string up into a stream of strings at newline characters. The resulting strings do not contain newlines.
lines = S.lines A.write
>>> Stream.fold Fold.toList $ Unicode.lines $ Stream.fromList "lines\nthis\nstring\n\n\n"
[fromList "lines",fromList "this",fromList "string",fromList "",fromList ""]