package ocaml-compiler
Install
dune-project
Dependency
Authors
Maintainers
Sources
sha256=22c1dd9de21bf43b62d1909041fb5fad648905227bf69550a6a6bef31e654f38
doc/compiler-libs.common/Format_doc/index.html
Module Format_doc
Composable document for the Format formatting engine.
This module introduces a pure and immutable document type which represents a sequence of formatting instructions to be printed by a formatting engine at later point. At the same time, it also provides format string interpreter which produces this document type from format string and their associated printers.
The module is designed to be source compatible with code defining format printers: replacing `Format` by `Format_doc` in your code will convert `Format` printers to `Format_doc` printers.
module Doc : sig ... endDefinitions and immutable API for composing documents
Compatibility API
The functions and types below provides source compatibility with format printers and conversion function from Format_doc printers to Format printers. The reverse direction is implemented using an escape hatch in the formatting instruction and should only be used to preserve backward compatibility.
type doc = Doc.ttype t = doctype 'a printer = formatter -> 'a -> unitformatter rdoc creates a formatter that updates the rdoc reference
type 'a format_printer = Format.formatter -> 'a -> unitTranslate a Format_doc printer to a Format one.
val compat : 'a printer -> 'a format_printerval compat1 : ('p1 -> 'a printer) -> 'p1 -> 'a format_printerval compat2 : ('p1 -> 'p2 -> 'a printer) -> 'p1 -> 'p2 -> 'a format_printerval deprecated_printer : (Format.formatter -> unit) -> formatter -> unitIf necessary, embbed a Format printer inside a formatting instruction stream. This breaks every guarantees provided by Format_doc.
val deprecated : 'a format_printer -> 'a printerval deprecated1 : ('p1 -> 'a format_printer) -> 'p1 -> 'a printerFormat string interpreters
doc_printf and kdoc_printf creates a document directly
Compatibility with Doc
val doc_printer : 'a printer -> 'a Doc.printerSource compatibility with Format
String printers
val pp_print_string : string printerval pp_print_substring : pos:int -> len:int -> string printerval pp_print_text : string printerval pp_print_bytes : bytes printerval pp_print_as : formatter -> int -> string -> unitval pp_print_substring_as :
pos:int ->
len:int ->
formatter ->
int ->
string ->
unitPrimitive type printers
val pp_print_char : char printerval pp_print_int : int printerval pp_print_float : float printerval pp_print_bool : bool printerval pp_print_nothing : unit printerPrinter combinators
Boxes and tags
val pp_open_stag : Format.stag printerval pp_close_stag : unit printerval pp_open_box : int printerval pp_close_box : unit printerBreak hints
val pp_print_space : unit printerval pp_print_cut : unit printerval pp_print_break : formatter -> int -> int -> unitval pp_print_custom_break :
formatter ->
fits:((string * int * string) as 'c) ->
breaks:'c ->
unitTabulations
val pp_open_tbox : unit printerval pp_close_tbox : unit printerval pp_set_tab : unit printerval pp_print_tab : unit printerval pp_print_tbreak : formatter -> int -> int -> unitNewlines and flushing
val pp_print_if_newline : unit printerval pp_force_newline : unit printerval pp_print_flush : unit printerval pp_print_newline : unit printerCompiler specific functions
Separators
val comma : unit printerCompiler output
val pp_two_columns :
?sep:string ->
?max_lines:int ->
formatter ->
(string * string) list ->
unitpp_two_columns ?sep ?max_lines ppf l prints the lines in l as two columns separated by sep ("|" by default). max_lines can be used to indicate a maximum number of lines to print -- an ellipsis gets inserted at the middle if the input has too many lines.
Example:
pp_two_columns ~max_lines:3 Format.std_formatter [ "abc", "hello"; "def", "zzz"; "a" , "bllbl"; "bb" , "dddddd"; ]
prints
abc | hello ... bb | dddddd