the-sett/elm-pretty-printer/1.0.0

NOTE: this package is not compatible with Elm 0.19.1

Pretty

Pretty printer.

type Doc

The type of documents that can be pretty printed.

Functions for building pieces of documents from string data.

empty : Doc

Creates an empty document.

pretty 10 empty == ""
space : Doc

Creates a document consisting of a single space.

string : String -> Doc

Creates a document from a string.

char : Char -> Doc

Creates a document from a character.

Functions for joining documents together

(|+) : Doc -> Doc -> Doc

Appends two documents together.

append : Doc -> Doc -> Doc

Appends two documents together.

join : Doc -> List Doc -> Doc

Concatenates a list of documents together interspersed with a separator document.

Functions for fitting documents onto lines as space allows.

group : Doc -> Doc

Tries to fit a document on a single line, replacing line breaks with single spaces where possible to achieve this.

line : Doc

Creates a hard line break. This always creates a new line, with subsequent text at the current indentation level.

softline : Doc

Creates a line break that will render to a single space if the documents it separtes can be fitted onto one line, or a line break otherwise.

Functions for indenting and alinging documents.

align : Doc -> Doc

Adds an indent of the current column position to all line breaks in the document. The first line will not be indented, only subsequent nested lines will be.

nest : Int -> Doc -> Doc

Adds an indent of the given number of spaces to all line breakss in the document. The first line will not be indented, only subsequent nested lines will be.

hang : Int -> Doc -> Doc

Adds an indent of the current column position to all line breaks in the document and a further indent of the specified number of columns. The first line will not be indented, only subsequent nested lines will be.

indent : Int -> Doc -> Doc

Indents a whole document by a given number of spaces.

Functions for putting brackets around documents.

surround : Doc -> Doc -> Doc -> Doc

Places a document inside left and right book ends.

pretty 100 (surround (char '\') (char '/') string "hello")
  == "\hello/"
parens : Doc -> Doc

Wraps a document in parnethesese

braces : Doc -> Doc

Wraps a document in braces.

pretty : Int -> Doc -> String

Pretty prints a document trying to fit it as best as possible to the specified column width of the page.

Functions for pretty printing documents.

pretty : Int -> Doc -> String

Pretty prints a document trying to fit it as best as possible to the specified column width of the page.