Format_state.Make
Functor constructing a concrete instance of a formatter.
module State : sig ... end
include Imperative_state.IMPERATIVE_STATE with type state = State.state
type state = State.state
traverse_list state f [x1; x2; ...; xn]
is [y1; y2; ...; yn]
where yi = f state xi
, and y1
, y2
, ..., yn
are computed in order, meaning that y1
is computed first, then y2
, etc.
iter_list state f [x1; x2; ...; xn]
is f state x1; f state x2; ...; f state xn
.
traverse_reverse_list state f [x1; x2; ...; xn]
is [y1; y2; ...; yn]
where yi = f state xi
, and y1
, y2
, ..., yn
are computed in reverse order, meaning that yn
is computed first, then y(n-1)
, etc.
iter_rev_list state f [x1; x2; ...; xn]
is f state xn; f state x(n-1); ...; f state x1
.
val pp_flush : state -> Stdlib.Unit.t
pp_flush state
is analogous to Format.pp_print_flush
.
val pp_newline : state -> Stdlib.Unit.t
pp_newline state
is analogous to Format.pp_print_newline
.
val pp_nop : state -> Stdlib.Unit.t
pp_nop state
is ()
. This is useful to signal that nothing should be printed for some execution branch.
val pp_cut : state -> Stdlib.Unit.t
pp_cut state
is analogous to Format.pp_print_cut
.
val pp_space : state -> Stdlib.Unit.t
pp_space state
is analogous to Format.pp_print_space
. Note that this is a possibly breaking space, meaning that a newline may be printed at this point.
val pp_non_breaking_space : state -> Stdlib.Unit.t
pp_non_breaking_space state
pretty-prints a non-breaking space, meaning that the printer does not insert break directives to that space.
pp_break state width offset
is analogous to Format.pp_print_break
.
pp_as state size
is analogous to Format.pp_print_as
to pretty-print a string as if it were of length size
. This is useful to pretty-print UTF-8 encoded strings of known codepoint count, or to print a string as if it isn't there, like for HTML tags or ASCII escape sequences.
pp_box state ?(indent = 0) f
evaluates f state
in a compacting pretty-printing box wth offset indent
in the formatter (see Format.pp_open_box
). The box is opened before f state
, and closed afterwards.
pp_hbox state f
evaluates f state
in a horizontal pretty-printing box (see Format.pp_open_hbox
). The box is opened before f state
, and closed afterwards.
pp_vbox state ?(indent = 0) f
evaluates f state
in a vertical pretty-printing box with offset indent
(see Format.pp_open_vbox
). The box is opened before f state
, and closed afterwards.
val pp_bool : state -> Stdlib.Bool.t -> Stdlib.Unit.t
val pp_float : state -> Stdlib.Float.t -> Stdlib.Unit.t
val pp_char : state -> Stdlib.Char.t -> Stdlib.Unit.t