Module Pretty

module Types : sig ... end
include module type of Types
type simple = (unit, Stdlib.Format.formatter, unit) Stdlib.format
type ('a, 'b) func = ('a, Stdlib.Format.formatter, unit, 'b) Stdlib.format4 -> 'a
type 'a proc = ('a, Stdlib.Format.formatter, unit) Stdlib.format -> 'a
type 'a printer = Stdlib.Format.formatter -> 'a -> unit
type 'a formatting = Stdlib.Format.formatter -> 'a
type delayed = unit formatting
val print : Stdlib.Format.formatter -> 'a proc
val out : 'a proc
val error : 'a proc
val sink : 'a proc
val delayed : ('a, delayed) func
val delayed_to : (delayed -> 'b) -> ('a, 'b) func
val pp_set_margin : Stdlib.Format.formatter -> int -> unit
val blast_margin : Stdlib.Format.formatter -> unit
val to_string : ('a, string) func
val string_to : (string -> 'b) -> ('a, 'b) func
val failwith : ('a, 'b) func
val invalid_arg : ('a, 'b) func
val failure : exn printer
val styles : Fmt.style list -> 'a printer -> 'a printer
val char : char printer
val string : string printer
val text : string printer
val int64 : int64 printer
val option : 'a printer -> 'a option printer
val list : ?fopen:simple -> ?fsep:simple -> ?fclose:simple -> ?fempty:simple -> 'a printer -> 'a list printer
val stack : 'a printer -> 'a list printer
val path : string list printer
val with_oxford_comma : ?comb:string -> 'a printer -> 'a list printer

with_oxford_comma ~comb pp ppf lst pretty-prints lst using ppf by enumerating its items and inserting Oxford-style comma. In particular, this function:

  • does nothing on an empty list;
  • acts like pp ppf e if lst = [e];
  • prints "a comb b" (without comma) in case lst = [a;b];
  • otherwise prints every element followed by a comma, except for the last that is preceded with "comb", as for instance in "a, b, c, and d".

comb is "and" by default; other sensible use is "or".

val record : ?opening:'a printer -> ?closing:'a printer -> 'a printer list -> 'a printer
val delayed_record : ?opening:unit printer -> ?closing:unit printer -> unit printer list -> delayed
val vfield : ?label:string printer -> ?sep:unit printer -> string -> ('a -> 'b) -> 'b printer -> 'a printer
type 'a conditional_field =
  1. | T of 'a printer
  2. | C of 'a -> bool * 'a printer
  3. | I of 'a -> bool * 'a printer * 'a printer
  4. | C' of bool * 'a printer
  5. | I' of bool * 'a printer * 'a printer
val record_with_conditional_fields : ?opening:'a printer -> ?closing:'a printer -> 'a conditional_field list -> 'a printer
module Simple : sig ... end
val init_formatters : ?style_renderer:Fmt.style_renderer -> ?utf_8:bool -> unit -> unit

Initialization of standard formatters; calls Fmt_tty.setup_std_outputs, and, depending on the kind of terminals they are bound to, adapts the margins of Fmt.stdout and Fmt.stderr. Their styles at that point are the ones set_colors restores with auto.

Colors

val set_colors : string -> (unit, string) Stdlib.result

set_colors spec sets whether Fmt.stdout and Fmt.stderr output colors (and other styles), according to spec: a comma-separated list of items WHEN or STREAM:WHEN, where STREAM is stdout or stderr, and WHEN is always, never or auto (as decided by init_formatters, from the kind of terminal they are bound to). An item without STREAM applies to both, and later items take precedence.

val colors_spec : unit -> string

colors_spec () is a specification for set_colors that gives the same styles as Fmt.stdout and Fmt.stderr currently output, e.g. "stdout:never,stderr:always".

Margins

val set_margins : string -> (unit, string) Stdlib.result

set_margins spec sets the margins (and maximum indentations) of Fmt.stdout and Fmt.stderr, according to spec: a comma-separated list of items GEOMETRY or STREAM:GEOMETRY, where STREAM is stdout or stderr, and GEOMETRY is MARGIN/MAX_INDENT or MARGIN (for a maximum indentation of MARGIN - 1), as accepted by Format.pp_set_geometry. An item without STREAM applies to both, and later items take precedence.

val margins_spec : unit -> string

margins_spec () is a specification for set_margins that gives the current margins (and maximum indentations) of Fmt.stdout and Fmt.stderr, e.g. "stdout:78/68,stderr:180/179".