stringbuilder-0.5.1: A writer monad for multi-line string literals

Safe Haskell | Safe-Inferred
Language | Haskell98

Data.String.Builder

Contents

- Functions
- Types

Description

The `build` function can be used to construct multi-line string literals in a monadic way:

    {-# LANGUAGE OverloadedStrings #-}

    import Data.String.Builder

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

Synopsis

- build :: Builder -> String
- literal :: String -> Builder
- type Builder = BuilderM ()
- data BuilderM a

# Functions

build :: Builder -> String Source #

Run a builder.

literal :: String -> Builder Source #

Add a literal string.

# Types

type Builder = BuilderM () Source #

data BuilderM a Source #

A writer monad for string literals.

#### Instances

Instances details

Applicative BuilderM Source # |
Instance details Defined in Data.String.Builder Methods pure :: a -> BuilderM a Source # (<*>) :: BuilderM (a -> b) -> BuilderM a -> BuilderM b Source # liftA2 :: (a -> b -> c) -> BuilderM a -> BuilderM b -> BuilderM c Source # (*>) :: BuilderM a -> BuilderM b -> BuilderM b Source # (<*) :: BuilderM a -> BuilderM b -> BuilderM a Source #
Functor BuilderM Source # |
Instance details Defined in Data.String.Builder Methods fmap :: (a -> b) -> BuilderM a -> BuilderM b Source # (<$) :: a -> BuilderM b -> BuilderM a Source #
Monad BuilderM Source # |
Instance details Defined in Data.String.Builder Methods (>>=) :: BuilderM a -> (a -> BuilderM b) -> BuilderM b Source # (>>) :: BuilderM a -> BuilderM b -> BuilderM b Source # return :: a -> BuilderM a Source #
Monoid Builder Source # |
Instance details Defined in Data.String.Builder Methods mempty :: Builder Source # mappend :: Builder -> Builder -> Builder Source # mconcat :: [Builder] -> Builder Source #
Semigroup Builder Source # |
Instance details Defined in Data.String.Builder Methods (<>) :: Builder -> Builder -> Builder Source # sconcat :: NonEmpty Builder -> Builder Source # stimes :: Integral b => b -> Builder -> Builder Source #
a ~ () => IsString (BuilderM a) Source # |
Instance details Defined in Data.String.Builder Methods fromString :: String -> BuilderM a Source #