Pretty.md

June 23, 2018 ยท View on GitHub

Module Text.Pretty

This module defines a set of combinators for pretty printing text.

Doc

newtype Doc

A text document.

width

width :: Doc -> Int

Get the width of a document.

height

height :: Doc -> Int

Get the height of a document.

render

render :: Doc -> String

Render a document to a string.

empty

empty :: Int -> Int -> Doc

An empty document

text

text :: String -> Doc

Create a document from some text.

beside

beside :: Doc -> Doc -> Doc

Place one document beside another.

atop

atop :: Doc -> Doc -> Doc

Place one document on top of another.

Stack

newtype Stack
  = Stack Doc

A wrapper for Doc with a Monoid instance which stacks documents vertically.

Instances
Newtype Stack _
Semigroup Stack
Monoid Stack

vcat

vcat :: forall f. Foldable f => f Doc -> Doc

Stack documents vertically

Columns

newtype Columns
  = Columns Doc

A wrapper for Doc with a Monoid instance which stacks documents in columns.

Instances
Newtype Columns _
Semigroup Columns
Monoid Columns

hcat

hcat :: forall f. Foldable f => f Doc -> Doc

Place documents in columns