package monolith
Library
Module
Module type
Parameter
Class
Class type
The submodule Print
offers facilities for printing OCaml values and expressions.
type 'a printer = 'a -> document
A printer transforms a value to into a document. A printer is said to be safe if it produces a document that is unambiguously delimited (e.g., delimited with parentheses). It is unsafe otherwise.
val int : int printer
int
is an integer literal printer. It is safe.
val bool : bool printer
bool
is a Boolean literal printer. It is safe.
val char : char printer
char
is a character literal printer. It is safe.
val string : string printer
string
is a string literal printer. It is safe.
result
is a result printer. It is safe.
parens
encloses its argument within a pair of parentheses. It is safe. If the document thus obtained does not fit a single line, then it is split over three lines and its content is indented by two spaces.
apply doc docs
constructs an OCaml application of doc
to the list of arguments docs
. The arguments are separated with spaces, and if the whole application does not fit on a line, then a flowing style is adopted, inserting a line break where necessary. This combinator is unsafe: the application is not parenthesized.
assert_ doc
constructs an OCaml assertion, that is, an application of the variable assert
to the document doc
, surrounded with parentheses. This combinator is unsafe: the assertion is not parenthesized.
comment doc
prints the document doc
inside a comment (preceded with a breakable space). It is safe.
candidate_finds doc
prints the document doc
inside a comment of the form (* candidate finds _ *)
. See e.g. the demo demos/working/bag
for an example of its use. It is safe.