A writer monad for multi-line string literals
Haskell
Switch branches/tags
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
src/Data/String
test Force result of IsString instance to be BuilderM () Sep 15, 2012
.ghci
.gitignore Initial commit Nov 23, 2011
.travis.yml Update travis-ci config Aug 6, 2012
CHANGES Update CHANGES, bump version Dec 2, 2012
LICENSE Bump version Aug 7, 2014
README.markdown Use syntax highlighting for examples in README Oct 9, 2012
Setup.lhs Initial commit Nov 23, 2011
stringbuilder.cabal Bump version Aug 7, 2014

README.markdown

About

build can be used to construct multi-line string literals in a monadic way.

{-# LANGUAGE OverloadedStrings #-}
import Data.String.Builder

str :: String
str = build $ do
  "foo"
  "bar"
  "baz"

This is primarily meant for test suites that use a lot of multi-line string literals, and when it really matters that the syntax is as easy on the eyes as it can get.

If you need just a few multi-line string literals in production code consider one of the following options first.

Haskell's support for multi-line string literals

help = "some\n\
       \multi-line\n\
       \help\n\
       \message\n"

Using unlines to construct multi-line string literals

help = unlines [
    "some"
  , "multi-line"
  , "help"
  , "message"
  ]