CCFormatHelpers for Format
val pp_open_box : formatter -> int -> unitval pp_close_box : formatter -> unit -> unitval pp_open_hbox : formatter -> unit -> unitval pp_open_vbox : formatter -> int -> unitval pp_open_hvbox : formatter -> int -> unitval pp_open_hovbox : formatter -> int -> unitval pp_print_string : formatter -> string -> unitval pp_print_bytes : formatter -> bytes -> unitval pp_print_as : formatter -> int -> string -> unitval pp_print_int : formatter -> int -> unitval pp_print_float : formatter -> float -> unitval pp_print_char : formatter -> char -> unitval pp_print_bool : formatter -> bool -> unitval pp_print_space : formatter -> unit -> unitval pp_print_cut : formatter -> unit -> unitval pp_print_break : formatter -> int -> int -> unitval pp_print_custom_break : 
  formatter ->
  fits:(string * int * string) ->
  breaks:(string * int * string) ->
  unitval pp_force_newline : formatter -> unit -> unitval pp_print_if_newline : formatter -> unit -> unitval pp_print_flush : formatter -> unit -> unitval pp_print_newline : formatter -> unit -> unitval pp_set_margin : formatter -> int -> unitval pp_get_margin : formatter -> unit -> intval pp_set_max_indent : formatter -> int -> unitval pp_get_max_indent : formatter -> unit -> intval check_geometry : geometry -> boolval pp_set_geometry : formatter -> max_indent:int -> margin:int -> unitval pp_safe_set_geometry : formatter -> max_indent:int -> margin:int -> unitval get_geometry : unit -> geometryval pp_set_max_boxes : formatter -> int -> unitval pp_get_max_boxes : formatter -> unit -> intval pp_over_max_boxes : formatter -> unit -> boolval pp_open_tbox : formatter -> unit -> unitval pp_close_tbox : formatter -> unit -> unitval pp_set_tab : formatter -> unit -> unitval pp_print_tab : formatter -> unit -> unitval pp_print_tbreak : formatter -> int -> int -> unitval pp_set_ellipsis_text : formatter -> string -> unitval pp_get_ellipsis_text : formatter -> unit -> stringval open_stag : stag -> unitval pp_close_stag : formatter -> unit -> unitval pp_set_tags : formatter -> bool -> unitval pp_set_print_tags : formatter -> bool -> unitval pp_set_mark_tags : formatter -> bool -> unitval pp_get_print_tags : formatter -> unit -> boolval pp_get_mark_tags : formatter -> unit -> boolval pp_set_formatter_out_channel : formatter -> Stdlib.out_channel -> unitval pp_set_formatter_output_functions : 
  formatter ->
  (string -> int -> int -> unit) ->
  (unit -> unit) ->
  unitval pp_get_formatter_output_functions : 
  formatter ->
  unit ->
  (string -> int -> int -> unit) * (unit -> unit)val pp_set_formatter_out_functions : 
  formatter ->
  formatter_out_functions ->
  unitval set_formatter_out_functions : formatter_out_functions -> unitval pp_get_formatter_out_functions : 
  formatter ->
  unit ->
  formatter_out_functionsval get_formatter_out_functions : unit -> formatter_out_functionsval pp_set_formatter_stag_functions : 
  formatter ->
  formatter_stag_functions ->
  unitval set_formatter_stag_functions : formatter_stag_functions -> unitval pp_get_formatter_stag_functions : 
  formatter ->
  unit ->
  formatter_stag_functionsval get_formatter_stag_functions : unit -> formatter_stag_functionsval formatter_of_out_channel : Stdlib.out_channel -> formatterval synchronized_formatter_of_out_channel : 
  Stdlib.out_channel ->
  formatter Stdlib.Domain.DLS.keyval std_formatter : formatterval get_std_formatter : unit -> formatterval err_formatter : formatterval get_err_formatter : unit -> formatterval formatter_of_buffer : Stdlib.Buffer.t -> formatterval str_formatter : formatterval get_str_formatter : unit -> formatterval make_formatter : 
  (string -> int -> int -> unit) ->
  (unit -> unit) ->
  formatterval make_synchronized_formatter : 
  (string -> int -> int -> unit) ->
  (unit -> unit) ->
  formatter Stdlib.Domain.DLS.keyval formatter_of_out_functions : formatter_out_functions -> formatterval make_symbolic_output_buffer : unit -> symbolic_output_bufferval clear_symbolic_output_buffer : symbolic_output_buffer -> unitval get_symbolic_output_buffer : 
  symbolic_output_buffer ->
  symbolic_output_item listval flush_symbolic_output_buffer : 
  symbolic_output_buffer ->
  symbolic_output_item listval add_symbolic_output_item : 
  symbolic_output_buffer ->
  symbolic_output_item ->
  unitval formatter_of_symbolic_output_buffer : symbolic_output_buffer -> formatterval pp_print_text : formatter -> string -> unitval printf : ('a, formatter, unit) Stdlib.format -> 'aval eprintf : ('a, formatter, unit) Stdlib.format -> 'aval asprintf : ('a, formatter, unit, string) Stdlib.format4 -> 'aval kasprintf : 
  (string -> 'a) ->
  ('b, formatter, unit, 'a) Stdlib.format4 ->
  'btype -'a printer = t -> 'a -> unitval silent : 'a printerPrints nothing.
val unit : unit printerPrints "()".
val int : int printerval string : string printerval bool : bool printerval float3 : float printerval float : float printerval exn : exn printerPrinter using Printexc.to_string.
val space : unit printerAlias to pp_print_space.
val cut : unit printerAlias to pp_print_cut.
val break : (int * int) printerTuple-ized printer form of pp_print_break.
val newline : unit printerForce newline (see Format.pp_force_newline).
val substring : (string * int * int) printersubstring (s,i,len) prints the substring (s,i,len), where i is the offset in s and len the number of bytes in the substring.
val text : string printerPrint string, but replacing spaces with breaks and newlines with newline. See pp_print_text on recent versions of OCaml.
val string_lines : string printerstring_lines out s prints s with all newlines ('\n') replaced by a cut, in a vertical box. It does NOT insert breakable spaces in place of spaces, unlike text. This means an already formatted string can be displayed inside another formatter without mangling the indentation.
val char : char printerval int32 : int32 printerval int64 : int64 printerval nativeint : nativeint printerval flush : unit printerAlias to Format.pp_print_flush.
val string_quoted : string printerSimilar to CCString.print.
opt pp prints options as follows:
Some x will become "some foo" if pp x ---> "foo".None will become "none".In the tuple printers, the sep argument is only available.
append ppa ppb first prints ppa (), then prints ppb ().
within a b p wraps p inside the strings a and b. Convenient, for instances, for brackets, parenthesis, quotes, etc.
val return : ('a, _, _, 'a) Stdlib.format4 -> unit printerreturn "some_format_string" takes a argument-less format string and returns a printer actionable by (). Examples:
return ",@ "return "@{<Red>and then@}@,"return "@[<v>a@ b@]"val of_to_string : ('a -> string) -> 'a printerof_to_string f converts its input to a string using f, then prints the string.
some pp will print options as follows:
Some x is printed using pp on xNone is not printed at allval const_string : string -> 'a printerconst_string s is a printer that ignores its input and always prints s.
val opaque : 'a printeropaque is const_string "opaque". The exact string used is not stable.
lazy_force pp out x forces x and prints the result with pp.
lazy_or ?default pp out x prints default if x is not evaluated yet, or uses pp otherwise.
Use ANSI escape codes https://en.wikipedia.org/wiki/ANSI_escape_code to put some colors on the terminal.
This uses tags in format strings to specify the style. Current styles are the following:
Example:
set_color_default true;;
Format.printf
  "what is your @{<White>favorite color@}? @{<blue>blue@}! No, @{<red>red@}! Ahhhhhhh@.";;status: unstable
val set_color_tag_handling : t -> unitAdd functions to support color tags to the given formatter.
set_color_default b enables color handling on the standard formatters (stdout, stderr) if b = true as well as on sprintf formatters; it disables the color handling if b = false.
with_color "Blue" pp behaves like the printer pp, but with the given style.
status: unstable
with_colorf "Blue" out "%s %d" "yolo" 42 will behave like Format.fprintf, but wrapping the content with the given style.
status: unstable
val with_color_sf : string -> ('a, t, unit, string) Stdlib.format4 -> 'awith_color_sf "Blue" out "%s %d" "yolo" 42 will behave like sprintf, but wrapping the content with the given style.
Example:
CCFormat.with_color_sf "red" "%a" CCFormat.Dump.(list int) [1;2;3] |> print_endline;;status: unstable
val with_color_ksf : 
  f:(string -> 'b) ->
  string ->
  ('a, t, unit, 'b) Stdlib.format4 ->
  'awith_color_ksf "Blue" ~f "%s %d" "yolo" 42 will behave like ksprintf, but wrapping the content with the given style.
Example: the following with raise Failure with a colored message
CCFormat.with_color_ksf "red" ~f:failwith "%a" CCFormat.Dump.(list int) [1;2;3];;module ANSI_codes : sig ... endANSI escape codes. This contains lower level functions for them.
val styling : ANSI_codes.style list -> 'a printer -> 'a printerstyling st p is the same printer as p, except it locally sets the style st.
Example:
open CCFormat;
set_color_default true;
sprintf
  "what is your %a? %a! No, %a! Ahhhhhhh@."
  (styling [`FG `White; `Bold] string) "favorite color"
  (styling [`FG `Blue] string) "blue"
  (styling [`FG `Red] string) "red"Available only on OCaml >= 4.08.
val with_styling : ANSI_codes.style list -> t -> (unit -> 'a) -> 'awith_styling style fmt f sets the given style on fmt, calls f(), then restores the previous style. It is useful in imperative-style printers (a sequence of "print a; print b; …").
Available only on OCaml >= 4.08.
val to_string : 'a printer -> 'a -> stringval of_chan : Stdlib.out_channel -> tAlias to Format.formatter_of_out_channel.
val with_out_chan : Stdlib.out_channel -> (t -> 'a) -> 'awith_out_chan oc f turns oc into a formatter fmt, and call f fmt. Behaves like f fmt from then on, but whether the call to f fails or returns, fmt is flushed before the call terminates.
val stdout : tval stderr : tval sprintf : ('a, t, unit, string) Stdlib.format4 -> 'aPrint into a string any format string that would usually be compatible with fprintf. Like Format.asprintf.
val sprintf_no_color : ('a, t, unit, string) Stdlib.format4 -> 'aLike sprintf but never prints colors.
val sprintf_dyn_color : 
  colors:bool ->
  ('a, t, unit, string) Stdlib.format4 ->
  'aLike sprintf but enable/disable colors depending on colors.
Example:
(* with colors *)
CCFormat.sprintf_dyn_color ~colors:true "@{<Red>%a@}"
  CCFormat.Dump.(list int) [1;2;3] |> print_endline;;
(* without colors *)
CCFormat.sprintf_dyn_color ~colors:false "@{<Red>%a@}"
  CCFormat.Dump.(list int) [1;2;3] |> print_endline;;Like fprintf but enable/disable colors depending on colors.
val ksprintf : 
  ?margin:int ->
  f:(string -> 'b) ->
  ('a, Stdlib.Format.formatter, unit, 'b) Stdlib.format4 ->
  'aksprintf fmt ~f formats using fmt, in a way similar to sprintf, and then calls f on the resulting string.
val to_file : string -> ('a, t, unit, unit) Stdlib.format4 -> 'aPrint to the given file.
Print structures as OCaml values, so that they can be parsed back by OCaml (typically, in the toplevel, for debugging).
Example:
Format.printf "%a@." CCFormat.Dump.(list int) CCList.(1 -- 200);;
Format.printf "%a@." CCFormat.Dump.(array (list (pair int bool)))
  [| [1, true; 2, false]; []; [42, false] |];;module Dump : sig ... endmodule Infix : sig ... end