package alba

  1. Overview
  2. Docs

Customizable pretty printer: Works with any printer which satisfies the PRINTER interface.

Parameters

module P : PRINTER

Signature

include SIG
type t

Type of a pretty printer.

val empty : t

The printer which prints nothing.

val substring : string -> int -> int -> t

substring s pos len: pretty printer printing a substring of s starting at pos and having length len.

val string : string -> t

string s: pretty printer printing the string s.

val char : char -> t

char s: pretty printer printing the character c.

val fill : int -> char -> t

fill n c: pretty printer printing the character c n times.

val line : string -> t

text s: pretty printer printing an optional line break with the alternative text s.

val cut : t

pretty printer printing an optional line break with no alternative text.

val space : t

pretty printer printing an optional line break with a blank as alternative text.

val nest : int -> t -> t

nest i pp: pretty printer printing the same content as pp but doing an additional indent of i at each line break.

val nest_list : int -> t list -> t

nest the list of pretty printers.

val nest_relative : int -> t -> t

nest i pp: pretty printer printing the same content as pp but doing an additional indent of i relative to the current position at each line break.

val group : t -> t

group pp: treat all line breaks appearing in pp consistently i.e. either output all as line breaks or all with their alternative text.

val group_list : t list -> t

group_list lst: group the list of pretty printers lst.

val wrap_words : string -> t

wrap_words s: Print the string s with all the words in it potentially wrapped.

val fill_paragraph : string -> t

fill_paragraph s: Print the string s as a paragraph i.e. putting as many words on a line as possible.

val (<+>) : t -> t -> t

p1 <+> p2 Print p1 and then p2.

val chain : t list -> t

chain list Print the list of printers.

val chain_separated : t list -> t -> t
val list_separated : t -> t list -> t
val run : int -> int -> int -> t -> P.t

run indent width ribbon pp: A printer generated from the pretty printer pp formatted with an initial indent, a line width and a ribbon width.

OCaml

Innovation. Community. Security.