the Genprint library uses the compilers’ type representation stored
in .cmt files to print.
it will print abstract types too from installed libraries as long as they
were compiled -bin-annot.
and here is an excerpt from the test file on creating a custom
printer for an abstract type:
let open Bigarray in
let open Array1 in
let a1=create Float32 C_layout 1 in
set a1 0 99.9;
(* this is abstract because it resides at the C level *)
[%pr bigarray abstracted a1];
let a1print ppf (a1: _ Array1.t) = Format.fprintf ppf "got it...%f" (get a1 0) in
(* %printer only accepts an identifier, not a closure *)
[%install_printer a1print];
(* now uses the printer *)
[%pr bigarray unmasked a1];
(* and the value directly *)
[%pr bigarray content(get a1 0 )];
(* and remove it... *)
[%remove_printer a1print];
[%pr bigarray abstract again a1];
the project repo also has a demo of the library integrated into the debugger.
nb. the availability of .cmt files is a runtime requirement, in-line
with the development focus of the library.