unlines

Appends a \n character to each input string, then concatenates the results. Equivalent to foldMap (s -> s ++ "\n").

Examples

>>> unlines ["Hello", "World", "!"]
"Hello\nWorld\n!\n"
Note that unlines . lines /= id when the input is not \n-terminated:
>>> unlines . lines $ "foo\nbar"
"foo\nbar\n"
unlines joins lines, appending a terminating newline after each. Equivalent to concat . Data.List.concatMap (\x -> [x, singleton '\n']).
O(n) Joins lines, after appending a terminating newline to each.
Insert a newline character after each incoming chunk of data. Subject to fusion
Appends a \n character to each input string, then concatenates the results. Equivalent to foldMap (s -> s ++ "\n").
>>> unlines ["Hello", "World", "!"]
"Hello\nWorld\n!\n"
Note that unlines . lines /= id when the input is not \n-terminated:
>>> unlines . lines $ "foo\nbar"
"foo\nbar\n"
Intersperses string chunks sent to the given OutputStream with newlines. See intersperse and unlines.
ghci> os <- Streams.unlines Streams.stdout
ghci> Streams.write (Just "Hello,") os
Hello
ghci> Streams.write Nothing os
ghci> Streams.write (Just "world!") os
world!
unlines takes list of Text values and joins them with line separator. Actual type of this function is the following:
unlines :: [Text] -> Text
but it was given a more complex type to provide friendlier compile time errors.
>>> unlines []
""

>>> unlines ["line 1"]
"line 1\n"

>>> unlines ["first line", "second line"]
"first line\nsecond line\n"

>>> unlines (["line 1", "line 2"] :: [String])
...
... 'unlines' 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.
...

>>> unlines [True, False]
...
... 'unlines' works with 'Text'
But given: 'Bool'
...
unlines is an inverse operation to lines. It joins lines, after appending a terminating newline to each.
>>> unlines ["Hello", "World", "!"]
"Hello\nWorld\n!\n"
Join a list of textual sequences using newlines.
> unlines ["abc","def","ghi"]
"abc\ndef\nghi"
Improper lens between lines and a bytestream 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.
The unlines function restores line breaks between layers. Note that this is not a perfect inverse of lines:
  • lines . unlines can produce more strings than there were if some of the "lines" had embedded newlines.
  • unlines . lines will replace \r\n with \n.
Joins lines
O(n) Joins lines, after appending a terminating newline to each.
Joins up lines by a newline character. It does not leave a newline after the last line. If you want a more classical unlines behaviour, use map along with snoc.
Concatenate documents after appending a terminating newline symbol to each.
unlines []                    == mempty
unlines [mempty]              == "\n"
unlines ["title", "subtitle"] == "title\nsubtitle\n"
The unlines function is an inverse operation to lines. It joins lines, after appending a terminating newline to each.
Flattens the stream of Array Char, after appending a terminating newline to each string. unlines is an inverse operation to lines.
>>> Stream.fold Fold.toList $ Unicode.unlines $ Stream.fromList ["lines", "this", "string"]
"lines\nthis\nstring\n"
unlines = S.unlines A.read
Note that, in general
unlines . lines /= id
Unfold a stream to character streams using the supplied Unfold and concat the results suffixing a newline character \n to each stream.
unlines = Stream.interposeSuffix 'n'
unlines = Stream.intercalateSuffix Unfold.fromList "n"
Pre-release
Concatenate lines together with \n. In contrast to their counterparts from Data.List, it holds that unlines . lines = id.
List version of $$. Note that: unlines = foldr ($$) mempty
Appends a n character to each input string, then concatenates the results. Equivalent to foldMap (s -> s ++ "n").
>>> unlines ["Hello", "World", "!"]
"Hello\nWorld\n!\n"

Note

unlines . lines /= id when the input is not n-terminated:
>>> unlines . lines $ "foo\nbar"
"foo\nbar\n"
Combine multiple lines with line break. Type-level version of the unlines function but for ErrorMessage.