HORIZON HASKELLDocslts/ghc-10.0.x8fef28d2026-11-02Search packagesCtrl K
Theme: |

GHC 10.0.0.20260917 · lts/ghc-10.0.x · 8fef28d · 2026-11-02

Moduletext-printer-0.5.0.2Haskell2010

Text.Printer

Monoids with a homomorphism from String to themselves.

Contents
  1. The class
  2. Builders
  3. Combinators
  4. Multiline printers
Synopsis

The class

classclass (IsString p, Semigroup p, Monoid p) => Printer p where

Text monoid. string must be equivalent to fromString and be a monoid homomorphism, i.e. string mempty = mempty and mappend (string x) (string y) = string (mappend x y). Other operations must be monoid homomorphisms that are eqiuvalent (but possibly faster) to the composition of string and the corresponding embedding, e.g. text = string . unpack.

Methods

Instances7Printer, …

Builders

newtypenewtype StringBuilder

A simple string builder as used by Show.

Instances6IsString, Generic, Semigroup, Monoid, Printer, Rep
newtypenewtype AsciiBuilder

Use this builder when you are sure that only ASCII characters will get printed to it.

Instances6IsString, Generic, Semigroup, Monoid, Printer, Rep
newtypenewtype Utf8Builder

UTF-8 lazy ByteString builder.

Instances6IsString, Generic, Semigroup, Monoid, Printer, Rep
newtypenewtype PrettyPrinter
#
Instances7IsString, Generic, Semigroup, Monoid, MultilinePrinter, Printer, …

Combinators

method(<>) :: a -> a -> a

An associative operation.

Examples
Example1 expression
[1,2,3] <> [4,5,6][1,2,3,4,5,6]
Example1 expression
Just [1, 2, 3] <> Just [4, 5, 6]Just [1,2,3,4,5,6]
Example1 expression
putStr "Hello, " <> putStrLn "World!"Hello, World!
valuefcat :: (Foldable f, Printer p) => (p -> p -> p) -> f p -> p

Combine the items of a Foldable data structure using the provided function. If the data structure is empty, mempty is returned.

Multiline printers

newtypenewtype LinePrinter p

A multiline printer that combines lines with the provided function.

Constructors

Instances7IsString, Generic, Semigroup, Monoid, MultilinePrinter, Printer, …