Text.Heredoc

heredoc-0.2.0.0: multi-line string / here document using QuasiQuotes

Safe Haskell | None
Language | Haskell98

Text.Heredoc

Synopsis

- here :: QuasiQuoter
- there :: QuasiQuoter
- str :: QuasiQuoter

# Documentation

here :: QuasiQuoter #

Create a string-literal expression from the string being quoted.

Newline literals are normalized to UNIX newlines (one '\n' character).

there :: QuasiQuoter #

Create a string-literal expression from the contents of the file at the filepath being quoted.

Newline literals are normalized to UNIX newlines (one '\n' character).

str :: QuasiQuoter #

Create a multi-line string literal whose left edge is demarcated by the "pipe" character ('|'). For example,

    famousQuote = [str|Any dictator would admire the
                      |uniformity and obedience of the U.S. media.
                      |
                      |    -- Noam Chomsky
                      |]

is functionally equivalent to

    famousQuote = "Any dictator would admire the\n" ++
                  "uniformity and obedience of the U.S. media.\n" ++
                  "\n" ++
                  "    -- Noam Chomsky\n"

If desired, you can have a ragged left-edge, so

    myHtml = [str|<html>
                     |<body>
                         |<h1>My home page</h1>
                     |</body>
                 |</html>
                 |]

is functionally equivalent to

    myHtml = "<html>\n" ++
             "<body>\n" ++
             "<h1>My home page</h1>\n" ++
              "</body>\n" ++
             "</html>\n"