Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] Custom prettyprinter for polymorphic datatype
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: John R Harrison <johnh@i...>
Subject: [Caml-list] Custom prettyprinter for polymorphic datatype

In CAML Light and OCaml, how do I install a custom printer for a
polymorphic datatype so that the subcomponents print in the usual way?

For example, suppose I decided to print lists with the elements
separated by "," instead of ";". (This is a bad idea of course, but
serves as a simple example.) Obviously I can write a recursive
function that passes over a list and does X at each element, but how
do I make X work on arbitrary types? Preferably as part of "X" the
custom printer would itself be called recursively if the elements
contain more lists.

If I could just get hold of a "standard printer" function

  print_value : 'a->unit

then presumably I could use that. Is this possible? Or is there a
better way?

John.
-------------------
To unsubscribe, mail caml-list-request@inria.fr.  Archives: http://caml.inria.fr