Module B0_std.Fmt
Textual formatters.
Helpers for dealing with Format.
Standard outputs and formatters
val stdout : Stdlib.Format.formatterstdoutoutputs to standard output.
val stderr : Stdlib.Format.formatterstderroutputs to standard error.
val flush : Stdlib.Format.formatter -> unitflushisFormat.pp_print_flush.
Formatting
val pf : Stdlib.Format.formatter -> ('a, Stdlib.Format.formatter, unit) Stdlib.format -> 'apfisFormat.fprintf.
val pr : ('a, Stdlib.Format.formatter, unit) Stdlib.format -> 'apfisFormat.printf.
val epr : ('a, Stdlib.Format.formatter, unit) Stdlib.format -> 'aeprisFormat.eprintf.
val str : ('a, Stdlib.Format.formatter, unit, string) Stdlib.format4 -> 'astr is
Format.asprintf.
val kpf : (Stdlib.Format.formatter -> 'a) -> Stdlib.Format.formatter -> ('b, Stdlib.Format.formatter, unit, 'a) Stdlib.format4 -> 'bkpfisFormat.kfprintf.
val kstr : (string -> 'a) -> ('b, Stdlib.Format.formatter, unit, 'a) Stdlib.format4 -> 'bkstr is
Format.kasprintf.
val failwith : ('b, Stdlib.Format.formatter, unit, 'a) Stdlib.format4 -> 'bfailwith fmt ...iskstr (fun s -> failwith s) fmt ...
val failwith_notrace : ('b, Stdlib.Format.formatter, unit, 'a) Stdlib.format4 -> 'bfailwith_notraceis likentbutFailureis raised withraise_notrace.
val invalid_arg : ('b, Stdlib.Format.formatter, unit, 'a) Stdlib.format4 -> 'binvalid_arg fmt ...iskstr (fun s -> invalid_arg s) fmt ...
val error : ('b, Stdlib.Format.formatter, unit, ('a, string) Stdlib.result) Stdlib.format4 -> 'berror fmt ...iskstr (fun s -> Error s) fmt ...
Formatters
type 'a t= Stdlib.Format.formatter -> 'a -> unitThe type for formatter of values of type
'a.
val nop : 'a tnopformats nothing.
val unit : (unit, Stdlib.Format.formatter, unit) Stdlib.Pervasives.format -> unit tunit fmtformats a unit value with the formatfmt.
val cut : unit tcutisFormat.pp_print_cut.
val sp : unit tspisFormat.pp_print_space.
val comma : unit tcommaisunit ",@ ".
Base type formatters
val bool : bool tboolisFormat.pp_print_bool.
val int : int tintisFormat.pp_print_int.
val int32 : int32 tint32ispf ppf "%ld".
val int64 : int64 tint64ispf ppf "%Ld".
val float : float tfloatispf ppf "%g".
val char : char tcharisFormat.pp_print_char.
val string : string tstringisFormat.pp_print_string.
val elided_string : max:int -> string telieded_string ~maxformats a string using at mostmaxcharacters, eliding it if it is too long with three consecutive dots which do count towardsmax.
val pair : ?sep:unit t -> 'a t -> 'b t -> ('a * 'b) tpair ~sep pp_fst pp_sndformats a pair. The first and second projection are formatted usingpp_fstandpp_sndand are separated bysep(defaults tocut).
val list : ?empty:unit t -> ?sep:unit t -> 'a t -> 'a list tlist ~sep pp_vformats list elements. Each element of the list is formatted in order withpp_v. Elements are separated bysep(defaults tocut). If the list is empty, this isempty(defaults tonop).
val array : ?empty:unit t -> ?sep:unit t -> 'a t -> 'a array tarray ~sep pp_vformats array elements. Each element of the array is formatted in in order withpp_v. Elements are seperated bysep(defaults tocut). If the array is empty this isempty(defauls tonop).
val option : ?none:unit t -> 'a t -> 'a option toption ~none pp_vformats an option. TheSomecase usespp_vandNoneusesnone(defaults tonop).
val none : unit tnoneisunit "<none>".
val iter : ?sep:unit t -> (('a -> unit) -> 'b -> unit) -> 'a t -> 'b titer ~sep iter pp_eltformats the iterations ofiterover a value usingpp_elt. Iterations are separated bysep(defaults tocut).
val iter_bindings : ?sep:unit t -> (('a -> 'b -> unit) -> 'c -> unit) -> ('a * 'b) t -> 'c titer_bindings ~sep iter pp_bindingformats the iterations ofiterover a value usingpp_binding. Iterations are separated bysep(defaults tocut).
val text : string ttextisFormat.pp_print_text.
val lines : string tlinesformats lines by replacing newlines ('\n') in the string with calls toFormat.pp_force_newline.
val exn : exn texnformats an exception.
val exn_backtrace : (exn * Stdlib.Printexc.raw_backtrace) texn_backtraceformats an exception backtrace.
Boxes
val box : ?indent:int -> 'a t -> 'a tbox ~indent pp ppfwrapsppin a horizontal or vertical box. Break hints that lead to a new line addindentto the current indentation (defaults to0).
val hbox : 'a t -> 'a thboxis likeboxbut is a horizontal box: the line is not split in this box (but may be in sub-boxes).
Quoting
Brackets
ANSI TTY styling
val set_tty_styling_cap : Tty.cap -> unitset_tty_styling_cap csets the global styling capabilities toc. Affects the output oftty_strand ANSI TTY styling.
val tty_styling_cap : unit -> Tty.captty_styling_cap ()is the global styling capability.
val tty_string : Tty.style list -> string ttty_string styles ppf sprintssonppfaccording tostylesand the value oftty_styling_cap.
val tty : Tty.style list -> 'a t -> 'a ttty styles pp_v ppf vprintsvwithpp_vonppfaccording tostylesand the value oftty_styling_cap.
Alternatives
Fields
Magnitudes
val si_size : scale:int -> string -> int tsi_size ~scale unitformats a non negative integer representing unitunitat scale 10scale * 3, depending on its magnitude, using power of 3 SI prefixes (i.e. all of them except deca, hector, deci and centi). Only US-ASCII characters are used,µ(10-6) is written usingu.scaleindicates the scale 10scale * 3 an integer represents, for example-1for munit(10-3),0forunit(100),1forkunit(103); it must be in the range [-8;8] orInvalid_argumentis 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).
val byte_size : int tbyte_sizeissi_size ~scale:0 "B".
val uint64_ns_span : int64 tuint64_ns_spanformats an unsigned nanosecond time span according to its magnitude using SI prefixes on seconds and accepted non-SI units. Years are counted in Julian years (365.25 SI-accepted days) as defined by the International Astronomical Union (IAU). Only US-ASCII characters are used (usis used forµs).