Wadler's Pretty printer. Use the constructor functions to build up a Doc and
lay it out to fit a page width using the pretty function.
Pretty prints a document trying to fit it as best as possible to the specified column width of the page.
Creates an empty document. Empties are discarded during pretty printing.
Note that the join, lines, softlines and words functions also filter
out empties. So if a list of Docs are joined by spaces any that are empty will
be dircarded and not result in a double space in the result. For this reason
empty is not the same as string "".
pretty 10 empty == ""Short hand notation for append. Usefull when appending multiple parts together:
string "Hello"
|> a space
|> a "World"
|> a (char '!')
|> a lineConcatenates a list of documents together interspersed with a separator document.
Any empty docs in the list are dropped, so that multiple separators will not be
placed together with nothing in between them. If this behaviour is intended use
string "" instead of empty.
Concatenate a list of documents together interspersed with lines. Very convenient when laying out lines after another:
lines
[ string "Heading"
, empty
, words [string "First", string "paragraph"]
...
]
==
string "Heading"
|> a line
|> a line
|> a (string "First")
|> a space
|> a (string "paragraph")
...Any empty docs in the list are dropped, so multiple lines will not be inserted around any empties.
See also words.
Like lines but uses softline instead.
Any empty docs in the list are dropped, so multiple lines will not be inserted around any empties.
Concatenate a list of documents together interspersed with spaces. Very convenient when laying out words after another.
See also lines.
Any empty docs in the list are dropped, so multiple spaces will not be inserted around any empties.
Fold a list of documents from left to right using a given function.
fold f == List.foldl f emptyTries to fit a document on a single line, replacing line breaks with single spaces where possible to achieve this.
Creates a hard line break. This always creates a new line, with subsequent text at the current indentation level.
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.
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.
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.
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.
Places a document inside left and right book ends.
pretty 100 (surround (char '\') (char '/') string "hello")
== "\hello/"
The type of documents that can be pretty printed.