A re-announcement of Genprint, a general value printing library, a new release that addresses prior limitations that made it none too useful!
- It didn’t work correctly for 4.08.0, the latest compiler release as of first announcement (though fine for 4.02 … 4.07.1)
- There was an awkward need to specify a search path for .cmt files when working with the likes of Dune (which uses separate directories for source, .cmi and (for opt) .cmt files)
- More often than not values of interest would display simply as
<abstr>
owing to the presence of signature abstraction of the module’s type of interest.
These issues have been addressed:
- Works with versions 4.04 … 4.10.0 (earlier versions became invalid after a dependency change to ppxlib)
- The location of .cmt files is captured automatically by the PPX preprocessor.
- Signatures at the implementation level (.mli files) and internally (functor application constraints) are removed to reveal the inner structure of otherwise abstract values.
For instance, the Ephemeron module:
module EM=Ephemeron.K1.Make(struct type t=int let equal=(=) let hash=Hashtbl.hash end)
open EM
let _=
let v=EM.create 0 in
EM.add v 12345678 'X';
let emprint ppf (v: Obj.Ephemeron.t) =
Format.fprintf ppf "<C wrapper of key/data>" in
[%install_printer emprint];
[%pr ephem v];
Which prints:
ephem => {size = 1;
data =
[|Empty; Empty; Empty; Empty; Empty; Empty; Empty; Empty; Empty;
Empty; Empty; Cons (922381915, <C wrapper of key/data>, Empty);
Empty; Empty; Empty; Empty|];
seed = 0; initial_size = 16}
This also demos the [%install_printer] facility which mirrors the REPL’s.
Installation is via the Opam main repository.
Additionally, the project repository contains two compiler versions of ocamldebug integrated with the Genprint library which thereby becomes its default printer.
All of which makes this library much more useful than previously.
See the project page for the details.