package monolith

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

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

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.

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

pair is a pair printer.

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

list is an alias for PPrint.OCaml.flowing_list.

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

array is an alias for PPrint.OCaml.flowing_array.

val parens : document -> document

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.

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.

val assert_ : document -> document

assert_ doc constructs an OCaml assertion, that is, an application of the variable assert to the document doc within parentheses.

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.

OCaml

Innovation. Community. Security.