type doc
doc represents documents which can be pretty printed. They are
constructed from functions provided by this module.
val empty : doc
val (^^) : doc -> doc -> doc
d1 ^^ d2 is the concatenation of documents d1 and d2.
val text : string -> doc
text "hello" creates a document containing the string "hello".
This operators simply turns strings into documents.
val break : doc
break represents a point where the pretty printer can decide
whether to begin a new line or not. In the former case a newline is
printed, followed by a number of spaces to indent the next line.
The number of spaces is controlled by the nest operator. When the
pretty printer does not begin a new line a single space is printed
for the break.
val breakWith : string -> doc
breakWith s acts like break except that it is not turned into a
space or a newline but into s or a newline (followed by spaces).
val nest : int -> doc -> doc
nest i doc: all breaks inside doc which are turned into
newlines will be followed by additional i spaces. Nesting adds up:
when doc contains another nest j operator the breaks inside its
document will follwed by i+j spaces.
val hgrp : doc -> doc
breaks inside a hgrp (horizontal group) are never turned into
newlines, so they always come out as spaces.
val vgrp : doc -> doc
breaks inside a vgrp (vertical group) are always turned onto
newlines (which are followed by spaces as indicated by nest).
val agrp : doc -> doc
The automatic group agrp is the most versatile: when the whole
group including all subgroups fits into one line breaks come out
as spaces. Otherwise breaks come out as newlines. However, this
does not affect subgroups: their breaks are considered
seperately.
val fgrp : doc -> doc
The break policy inside an agrp is fixed for all breaks of the
group. Inside a flexible group fgrp each break is considered
individually: when the document up to the next break fits into the
current line the break comes out as space. Otherwise it comes out
as newline followed by spaces.
val ppToString : int -> doc -> string
ppToString w doc formats doc for line length w (> 0) and
returns it as string. This is not efficient and should be avoided
for large documents. The document is considered to be surrounded
by a virtual agrp - if this is not desried it should have itself
a different group at its outermost level to protect itself from
the agrp.
val ppToFile : out_channel -> int -> doc -> unit
ppToFile oc w doc pretty prints doc for line length w into an
output channel oc. The document is considered to be surrounded
by a virtual agrp - if this is not desried it should have itself
a different group at its outermost level to protect itself from
this agrp.
Go to the first, previous, next, last section, table of contents.