Logo

Programming-Idioms

History of Idiom 48 > diff from v45 to v46

Edit summary for version 46 by gesh:
[Haskell] use `unlines`: cleaner, will be optimized away

Version 45

2019-02-01, 06:25:16

Version 46

2019-02-12, 11:38:23

Idiom #48 Multi-line string literal

Assign to variable s a string literal consisting in several lines of text

Idiom #48 Multi-line string literal

Assign to variable s a string literal consisting in several lines of text

Extra Keywords
multiline raw
Extra Keywords
multiline raw
Code
s = "several\n\
    \lines\n\
    \of\n\
    \text\n"
Code
s = unlines [
     "several"
    ,"lines"
    ,"of"
    ,"text"]
Comments bubble
unlines concatenates a list of strings, inserting a newline between each. It is inverse to lines, which splits a string by newlines
Doc URL
http://hackage.haskell.org/packages/archive/base/latest/doc/html/Prelude.html#v:unlines