package b0
Install
dune-project
Dependency
Authors
Maintainers
Sources
sha512=00a6868b4dfa34565d0141b335622a81a0e8d5b9e3c6dfad025dabfa3df2db2a1302b492953bbbce30c3a4406c324fcec25250a00b38f6d18a69e15605e3b07e
doc/b0.std/B0_std/Fmt/index.html
Module B0_std.FmtSource
Textual formatters.
Helpers for dealing with Format.
Standard outputs
stdout outputs to standard output.
stderr outputs to standard error.
Formatting
pf is Format.fprintf.
pf is Format.printf.
epr is Format.eprintf.
str is Format.asprintf.
val kpf :
(Format.formatter -> 'a) ->
Format.formatter ->
('b, Format.formatter, unit, 'a) format4 ->
'bkpf is Format.kfprintf.
kstr is Format.kasprintf.
failwith fmt ... is kstr failwith fmt ...
failwith_notrace is like failwith but Failure is raised with raise_notrace.
invalid_arg fmt ... is kstr invalid_arg fmt ...
error fmt ... is kstr (fun s -> Error s) fmt ...
Formatters
The type for formatter of values of type 'a.
flush has the effect of Format.pp_print_flush.
flush_nl has the effect of Format.pp_print_newline.
any fmt formats any value with fmt.
Separators
cut has the effect of Format.pp_print_cut.
sp has the effect of Format.pp_print_space.
sps n has the effect of Format.pp_print_break n 0.
Sequencing
iter ~sep iter pp_elt formats the iterations of iter over a value using pp_elt. Iterations are separated by sep (defaults to cut).
iter_bindings ~sep iter pp_binding formats the iterations of iter over a value using pp_binding. Iterations are separated by sep (defaults to cut).
concat ~sep pps concatenates the formatters pps separating them with sep (defaults to cut).
Boxes
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).
hbox is like box but is a horizontal box: the line is not split in this box (but may be in sub-boxes).
vbox is like box but is a vertical box: every break hint leads to a new line which adds indent to the current indentation (default to 0).
hovbox is a condensed box, see Format.pp_open_hovbox.
Brackets
quote ~mark pp_v ppf is pf "@[<1>@<1>%s%a@<1>%s@]" mark pp_v mark, mark defaults to "\"", it is always counted as spanning as single column (this allows for UTF-8 encoded marks).
Records
field ~label ~sep l prj pp_v pretty prints a labelled field value as pf "@[<1>%a%a%a@]" label l sep () (using prj pp_v). label defaults to tty_string [`Yellow] and sep to any ":@ ".
record ~sep fields pretty-prints a value using the concatenation of fields, separated by sep (defaults to cut) and framed in a vertical box.
Stdlib types
Formatters for structures give full control to the client over the formatting process and do not wrap the formatted structures with boxes.
bool is Format.pp_print_bool.
int is Format.pp_print_int.
char is Format.pp_print_char.
string is Format.pp_print_string.
sys_signal formats an OCaml signal number as a C POSIX constant or "SIG(%d)" if the signal number is unknown.
backtrace formats a backtrace.
exn_backtrace formats an exception backtrace.
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 cut).
option ~none pp_v formats an option. The Some case uses pp_v and None uses none (defaults to nop).
Magnitudes
si_size ~scale unit formats a non negative integer representing unit unit at scale 10scale * 3, depending on its magnitude, using power of 3 SI prefixes (i.e. all of them except deca, hector, deci and centi). The output is UTF-8 encoded, it uses U+03BC for µ (10-6).
scale indicates the scale 10scale * 3 an integer represents, for example -1 for munit (10-3), 0 for unit (100), 1 for kunit (103); it must be in the range [-8;8] or Invalid_argument is raised.
Except at the maximal yotta scale always tries to show three digits of data with trailing fractional zeros omited. Rounds towards positive infinity (over approximates).
uint64_ns_span formats an unsigned nanosecond time span according to its magnitude using SI prefixes on seconds and non-SI units. Years are counted in Julian years (365.25 SI-accepted days) as defined by the International Astronomical Union.
Rounds towards positive infinity, i.e. over approximates, no duration is formatter shorter than it is.
The output is UTF-8 encoded, it uses U+03BC for µs (10-6s).
Text and lines
text is Format.pp_print_text.
lines formats lines by replacing newlines ('\n') in the string with calls to Format.pp_force_newline.
truncated ~max formats a string using at most max characters. If the string doesn't fit, it is truncated and ended with … (U+2026) which does count towards max.
HCI fragments
and_enum ~empty pp_v ppf l formats l according to its length.
0, formatsempty(defaults tonop).1, formats the element withpp_v.2, formats"%a and %a"with the list elementsn, formats"%a, ... and %a"with the list elements
or_enum is like and_enum but uses "or" instead of "and".
unknown ~kind pp_v formats "Unknown %a %a." kind () pp_v.
unknown ~kind pp_v ~hint (v, hints) formats unknown followed by a space and hint pp_v hints if hints is non-empty.
ANSI TTY styling
set_tty_cap ?cap () sets the global TTY formatting capabilities to cap if specified and to Tty.(cap (of_fd Unix.stdout)) otherwise. . Affects the output of tty_str and tty.
tty_string styles ppf s prints s on ppf according to styles and the value of tty_styling_cap.
tty styles pp_v ppf v prints v with pp_v on ppf according to styles and the value of tty_styling_cap.