The representation type of pretty-printable documents.
The operations provided by a pretty-printable document that don't depend on the document's representation type.
Indentation is expressed as integer space units.
The final layout of a document
Interface for pretty-printable values.
Output medium width
An empty document.
An empty document. This is a left and right unit for the concatenation
method. Called nil
in the paper.
A document representing a choice among different ways to print a structure.
A document representing a potential line break.
A document representing a potential line break. Behaves like space
if the break is omitted by a group.
A document representing a potential line break.
A document representing a potential line break. Behaves like empty
if the break is omitted by a group.
Nest a document by an indentation increment on top of the current nesting.
Nest a document by an indentation increment on top of the current nesting. In the paper version, the indentation parameter comes first, but we put it second here so that it can be given a default value.
Pretty print a document assuming a given output medium width.
Pretty print a document assuming a given output medium width. In the paper the width is the first parameter, but here we put it second so we can provide a default value.
Convert a string to a document.
Convert a string to a document. The string should not contain any
newline characters. Use line
instead.
An ampersand document.
Return a document that encloses a given document between left and right angle brackets.
Generic pretty-printer document for any type of value.
Generic pretty-printer document for any type of value. If a
is a
Vector
, Map
, List
or Product
, print it in a prefix list style,
with the exception that Nil
prints as Nil
. Tuples are pretty-printed
using arrow notation. Strings are pretty-printed surrounded by double
quotes. If none of these cases apply, use the toDoc
method on a
.
null
prints as null
.
Convert any value into a pretty-printable value.
Convert any value into a pretty-printable value. The value will
be pretty-printed using the value
combinator.
An asterisk document.
An at-sign document.
A backquote document.
A backslash document.
Return a document that encloses a given document between left and right braces.
Return a document that encloses a given document between left and right square brackets.
A caret document.
Return a document that concatenates the documents in the given sequence
either horizontally with <>
if they fit in the output medium width,
or if not, vertically with <@@>
.
Convert a character to a document.
Convert a character to a document. The character can be a newline.
A colon document.
A comma document.
Default indentation is four spaces.
Default layout width is 75 characters.
A dollar sign document.
A dot (period) document.
A double quote document.
Return a document that encloses a given document between double quotes.
Return a document that encloses a given document between left and right documents.
An equal sign document.
An exclamation mark document.
Return a document that concatenates the documents in the given sequence
horizontally with <>
as long as they fit the output width, then
inserts a linebreak
and continues to the end of the sequence.
Return a document that concatenates the documents in the given sequence
horizontally with <+>
as long as they fit the output width, then
inserts a line
and continues with the rest of the sequence.
Return a document that concatenates the documents in the given sequence
horizontally with <+>
as long as they fit the output width, then
inserts a line
and continues with the rest of the sequence. Separates
documents with the given separator before the <+>
.
Return a document that concatenates the documents in the given sequence
horizontally with <+>
as long as they fit the output width, then
inserts a line
and continues with the rest of the sequence.
A forward slash document.
A hash mark document.
Return a document that concatenates the documents in the given sequence
horizontally with <>
.
Return a document that concatenates the documents in the given sequence
horizontally with <+>
.
Return a document that concatenates the documents in the given sequence
horizontally with <+>
. Separates documents with the given separator
before the <+>
.
Return a document that concatenates the documents in the given sequence
horizontally with <+>
.
A left angle bracket document.
A left brace document.
A left square bracket document.
Return a document that pretty-prints a list in Scala notation, inserting line breaks between elements as necessary.
Return a document that pretty-prints a list in Scala notation,
inserting line breaks between elements as necessary.
The prefix
string can be changed from the default "List"
.
The elemToDoc
argument can be used to alter the way each element
is converted to a document (default: use the value
combinator).
sep
defaults to comma
.
A left parenthesis document.
Return a pretty-printer document for a separated sequence.
Return a pretty-printer document for a separated sequence.
sep
is the separator. Line breaks are allowed before the sequence
and after the separators between the elements of the sequence. The
before line break turns into nothing if omitted. The internal line
breaks turn into space
if omitted.
Return a pretty-printer document for a separated sequence.
Return a pretty-printer document for a separated sequence.
sep
is the separator. Line breaks are allowed before the separators
between the elements of the sequence and at the end. A space
is
inserted after each separator. The internal line breaks turn into
space
if omitted. The end line break turns into nothing if omitted.
Return a pretty-printer document for a sequence where each element
is terminated by term
.
Return a pretty-printer document for a sequence where each element
is terminated by term
. Line breaks are allowed before the sequence
and after the terminator between the elements of the sequence. The
before line break turns into nothing if omitted. The internal line
breaks turn into space
if omitted.
An minus sign document.
Return a document that encloses a given document between left and right parentheses.
A percent sign document.
Return a document that pretty-prints a list of pretty-printables in Scala notation, inserting line breaks between elements as necessary.
Return a document that pretty-prints a list of pretty-printables
in Scala notation, inserting line breaks between elements as necessary.
The prefix
string can be changed from the default "List"
.
The elemToDoc
argument can be used to alter the way each element
is converted to a document (default: call the element's toDoc
method).
sep
defaults to a comma
.
An plus sign document.
Pretty-print a pretty-printable value.
Pretty-print a pretty-printable value. If the value passed is not a
pretty-printable document, it will be converted to one using the implicit
conversion anyToPrettyPrintable
.
Pretty-print any value using the any
method.
A question mark document.
A right angle bracket document.
A right brace document.
A right square bracket document.
A right parenthesis document.
A semicolon document.
Return a document that concatenates the documents in the given sequence
either horizontally with <+>
if they fit in the output medium width,
or if not, vertically with <@>
.
Return a document that behaves like empty
if the resulting output
fits the page, otherwise it behaves like line
.
Return a document that behaves like space
if the resulting output
fits the page, otherwise it behaves like line
.
A space document.
Return a document representing n
spaces if n
s greater than zero,
otherwise return an empty document.
A single quote document.
Return a document that encloses a given document between single quotes.
Return a document that concatenates the documents in the given sequence
and separates adjacent documents with sep
with no space around the
separator.
Return a document that concatenates the documents in the given sequence
and terminates each document with term
.
Convert a string to a document.
Convert a string to a document. The string is allowed to contain
newline characters. If no newlines are included, it is best to
use text
directly instead.
Return a document that encloses a given document d
between two
occurrences of another document b
.
A tilde document.
An underscore document.
Return a document representing a value formatted using toString
and
the string
combinator.
Return a document representing a value formatted using toString
and
the string
combinator. As a special case, if the value is a null
reference it is formatted as null
.
Return a document that concatenates the documents in the given sequence
vertically with <@@>
.
A vertical bar document.
Return a document that concatenates the documents in the given sequence
vertically with <@>
.
Return a document that concatenates the documents in the given sequence
vertically with <@>
. Separates documents with the given separator
before the <@>
.
Return a document that concatenates the documents in the given sequence
vertically with <@>
.
The interface of a pretty printer using combinators from Swierstra and Chitil (Linear, bounded, functional pretty-printing, Journal of Functional Programming, 19 (1), 2009) and Leijen's PPrint library. The latter is a version of Wadler's library which was inspired by an earlier library by Hughes.