Library
Module
Module type
Parameter
Class
Class type
The submodule Print
offers a few facilities for printing OCaml values and expressions. It is meant to serve as a complement for the modules PPrint
and PPrint.OCaml
, which are part of the library pprint
.
type 'a printer = 'a -> document
A printer maps a value to a PPrint
document.
val int : int printer
Whereas PPrint.OCaml.int i
displays the integer i
naked, this int
combinator encloses i
within a pair of parentheses if it is negative. This ensures that int i
can safely be used as an argument in an application.
Whereas PPrint.OCaml.option
prints Some(2)
, this option
combinator prints (Some 2)
. This ensures that option element o
can safely be used as an argument in an application.
Whereas PPrint.parens
simply encloses a document in parentheses, this parens
combinator encloses the document within parentheses and specifies that if the whole thing does not fit a single line, then it must be split over three lines and the content must be 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.
assert_ doc
constructs an OCaml assertion, that is, an application of the variable assert
to the document doc
within parentheses.