Module B0.Fmt

module Fmt: sig .. end
Format combinators.


Formatting


val pf : Format.formatter -> ('a, Format.formatter, unit) Pervasives.format -> 'a
pf is Format.fprintf.

Formatters


type 'a t = Format.formatter -> 'a -> unit 
The type for formatter of values of type 'a.
val nop : 'a t
nop formats nothing.
val cut : unit t
cut is Format.pp_print_cut.
val sp : unit t
sp is Format.pp_print_space.
val comma : unit t
comma is unit ",@ ".
val unit : (unit, Format.formatter, unit) Pervasives.format -> unit t
unit fmt formats a unit value with the format fmt.

Base type formatters


val bool : bool t
bool is Format.pp_print_bool.
val int : int t
int is pf ppf "%d".
val char : char t
char is Format.pp_print_char.
val string : string t
string is Format.pp_print_string.
val pair : ?sep:unit t -> 'a t -> 'b t -> ('a * 'b) t
pair ~sep pp_fst pp_snd formats a pair. The first and second projection are formatted using pp_fst and pp_snd and are separated by sep (defaults to B0.Fmt.cut).
val list : ?sep:unit t -> 'a t -> 'a list t
list sep pp_v formats list elements. Each element of the list is formatted in order with pp_v. Elements are separated by sep (defaults to B0.Fmt.cut). If the list is empty, this is B0.Fmt.nop.
val option : ?none:unit t -> 'a t -> 'a option t
option ~none pp_v formats an optional value. The Some case uses pp_v and None uses none (defaults to B0.Fmt.nop).
val iter : ?sep:unit t ->
(('a -> unit) -> 'b -> unit) -> 'a t -> 'b t
iter ~sep iter pp_elt formats the iterations of iter over a value using pp_elt. Iterations are separated by sep (defaults to B0.Fmt.cut).
val iter_bindings : ?sep:unit t ->
(('a -> 'b -> unit) -> 'c -> unit) -> ('a * 'b) t -> 'c t
iter_bindings ~sep iter pp_binding formats the iterations of iter over a value using pp_binding. Iterations are separated by sep (defaults to B0.Fmt.cut).
val text : string t
text is .
val lines : string t
lines formats lines by replacing newlines ('\n') in the string with calls to Format.pp_force_newline.
val exn : exn t
exn formats an exception.
val exn_backtrace : (exn * Printexc.raw_backtrace) t
exn_backtrace formats an exception backtrace.

Boxes


val box : ?indent:int -> 'a t -> 'a t
box ~indent pp ppf wraps pp in a horizontal or vertical box. Break hints that lead to a new line add indent to the current indentation (defaults to 0).
val hbox : 'a t -> 'a t
hbox is like B0.Fmt.box but is a horizontal box: the line is not split in this box (but may be in sub-boxes).
val vbox : ?indent:int -> 'a t -> 'a t
vbox is like B0.Fmt.box but is a vertical box: every break hint leads to a new line which adds indent to the current indentation (default to 0).
val hvbox : ?indent:int -> 'a t -> 'a t
hvbox is like B0.Fmt.box but is either B0.Fmt.hbox if its fits on a single line or B0.Fmt.vbox otherwise.

Brackets


val parens : 'a t -> 'a t
parens pp_v ppf is pf "@[<1>(%a)@]" pp_v.
val brackets : 'a t -> 'a t
brackets pp_v ppf is pf "@[<1>[%a]@]" pp_v.
val braces : 'a t -> 'a t
braces pp_v ppf is pf "@[<1>{%a}@]" pp_v.

Fields


val field_label : string t
field_label l pretty prints a field label l.
val field : string -> 'a t -> 'a t
field l pp_v pretty prints a field with label l using pp_v to print the value.