deepfire / stringbuilder

A writer monad for multi-line string literals

Home Page:http://hackage.haskell.org/package/stringbuilder

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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"
  ]

About

A writer monad for multi-line string literals

http://hackage.haskell.org/package/stringbuilder

License:MIT License


Languages

Language:Haskell 100.0%