package base
Install
Dune Dependency
Authors
Maintainers
Sources
sha256=755e303171ea267e3ba5af7aa8ea27537f3394d97c77d340b10f806d6ef61a14
doc/base/Base/Pretty_printer/index.html
Module Base.Pretty_printer
Source
A list of pretty printers for various types, for use in toplevels.
Pretty_printer
has a string list ref
with the names of pp
functions matching the interface:
val pp : Format.formatter -> t -> unit
The names are actually OCaml identifier names, e.g., "Base.Int.pp". Code for building toplevels evaluates the strings to yield the pretty printers and register them with the OCaml runtime.
This module is only responsible for collecting the pretty-printers. Another mechanism is needed to register this collection with the "toploop" library for pretty-printing to actually happen. How to do that depends on how you build and deploy the OCaml toplevel. One common way to do it in vanilla toplevel is to call #require "core.top"
.
all ()
returns all pretty printers that have been register
ed.
Register
builds a pp
function from a to_string
function, and adds the module_name ^ ".pp"
to the list of pretty printers. The idea is to statically guarantee that one has the desired pp
function at the same point where the name
is added.
Register_pp
is like Register
, but allows a custom pp
function rather than using to_string
.
register name
adds name
to the list of pretty printers. Use the Register
functor if possible.