package smart-print

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type

SmartPrint library.

type t

The document's abstract type.

val empty : t

The empty document.

val string : string -> t

A non-breakable string. The string should be newlines free.

val sub_string : string -> int -> int -> t

A non-breakable string pointing to the sub-string of an existing string. Does not duplicate the sub-string. The sub-string is indexed by its offset and its length.

val (!^) : string -> t

A shortcut for string.

val space : t

A breakable space.

val newline : t

A newline.

val append : t -> t -> t

Concatenation of two documents.

val (^-^) : t -> t -> t

A shortcut for append.

val concat_with_space : t -> t -> t

Concatenation of two documents with a breakable space in between. Like d1 ^-^ space ^-^ d2.

val (^^) : t -> t -> t

A shortcut for concat_with_space. Like d1 ^-^ space ^-^ d2.

val words : string -> t

Split a non-unicode string into words and breakable spaces.

val lines : string -> t

Split a non-unicode string into lines at each newline.

val indent : t -> t

Add one level of indentation.

val nest : t -> t

Group a document, breaking spaces only when necessary. Indent when spaces are broken.

val nest_all : t -> t

Group a document, breaking all spaces if the line is full. Indent when spaces are broken.

val group : t -> t

Group a document, breaking spaces only when necessary. Do not indent when spaces are broken.

val group_all : t -> t

Group a document, breaking all spaces if the line is full. Do not indent when spaces are broken.

val parens : t -> t

Enclose the document in parenthesis ( ).

val braces : t -> t

Enclose the document in braces { }.

val brakets : t -> t

Enclose the document in brakets [ ].

val angle_brakets : t -> t

Enclose the document in angle brakets < >.

val single_quotes : t -> t

Enclose the document in single quotes ' '.

val double_quotes : t -> t

Enclose the document in double quotes " ".

val concat : t list -> t

Concatenate the list of documents with no space. concat [d1; ...; dn] = d1 ^-^ ... ^-^ dn

val separate : t -> t list -> t

Concatenate the list of documents with no space but adding a separator in between. separate sep [d1; ...; dn] = d1 ^-^ sep ^-^ d2 ^-^ sep ... sep ^-^ dn

module OCaml : sig ... end

Pretty-printing of OCaml values.

module Debug : sig ... end

A pretty-printer for the pretty-printer itself.

val to_something : int -> int -> (char -> unit) -> (string -> unit) -> (string -> int -> int -> unit) -> t -> unit

Render a document with a maximal width per line and a tabulation size. Uses the functions add_char, add_string and add_sub_string given.

val to_buffer : int -> int -> Buffer.t -> t -> unit

Render a document in a buffer with a maximal width per line and a tabulation size.

val to_string : int -> int -> t -> string

Render a document in a string with a maximal width per line and a tabulation size.

val to_out_channel : int -> int -> out_channel -> t -> unit

Render a document in an output channel with a maximal width per line and a tabulation size.

val to_stdout : int -> int -> t -> unit

Render a document on stdout with a maximal width per line and a tabulation size.

OCaml

Innovation. Community. Security.