package pprint

  1. Overview
  2. Docs

A custom document is defined by implementing an object of class custom.

method requirement : requirement

A custom document must publish the width (i.e., the number of columns) that it would like to occupy if printed on a single line (in flat mode). The special value infinity means that this document cannot be printed on a single line; this value causes any groups that contain this document to be dissolved. This method should in principle work in constant time.

method pretty : output -> state -> int -> bool -> unit

The method pretty is used by the main rendering algorithm. It has access to the output channel and to the printing engine's internal state. In addition, it receives the current indentation level and a Boolean flag that tells whether the engine is currently in flat mode. If the engine is in flat mode, then the document must be printed on a single line, in a manner that is consistent with the width requirement that was published ahead of time. If the engine is in normal mode, then there is no such obligation. The state must be updated in a manner that is consistent with what is sent to the output channel.

method compact : output -> unit

The method compact is used by the compact rendering algorithm. It has access to the output channel only.

OCaml

Innovation. Community. Security.