package monolith

  1. Overview
  2. Docs
Legend:
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.

val option : 'a printer -> 'a option printer

option is an option printer. It is safe.

val result : 'a printer -> 'b printer -> ('a, 'b) result printer

result is a result printer. It is safe.

val pair : 'a printer -> 'b printer -> ('a * 'b) printer

pair is a pair printer. It is safe.

val list : 'a printer -> 'a list printer

list is a list printer. It is safe.

val array : 'a printer -> 'a array printer

array is an array printer. It is safe.

val parens : document -> document

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.

val apply : document -> document list -> document

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.

val assert_ : document -> document

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.

val comment : document -> document

comment doc prints the document doc inside a comment (preceded with a breakable space). It is safe.

val candidate_finds : document -> document

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.

OCaml

Innovation. Community. Security.