Say I have my own data structure, as a silly example,
type 'a mylist = Empty | Cons of 'a * ('a mylist)
.
I would like the toplevel to print this list in the form {a,b,...}
. Here a
, b
of type 'a
are printed according to a printing function installed in the toplevel with #install_printer, or if none is available, as <abstr>
.
I know how I would define a printing function for a monomorphic mylist, but is there a polymorphic way to tell the toplevel to just put {
, ,
and }
and use what it already knows for any type that comes in between?