Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
[Caml-list] Polymorphic pretty printing
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Andrej Bauer <Andrej.Bauer@a...>
Subject: [Caml-list] Polymorphic pretty printing
This is a question for gurus.

I am contemplating writing an enhanced toplevel that could display
graphics as we well as text (the evil plan is to replace Mathematica).
The first step seems to be: how to install a pretty printer for a
_polymorphic_ type.

As an example, consider this:

  type 'a set = { elements : 'a list }

I want a value of this type to print out as

  {a, b, c, ... d}

instead of

  {elements = [a; b; c; ...; d]}

The trouble is, how to print out the elements a, b, c, ..., d
since they are of a polymorphic type.

According to the somewhat old message at

I should use Toplevel.print_out_value to do this. But, print_out_value
expects an arguments of type Outcometree.out_value, and it is not
clear to me where I will get it. Is there another function that converts
an arbitrary value (of an arbitrary type!) to an Outcometree.out_value?

Am I supposed to rewrite half of to get this working?

It would be helpful if there were, somewhere in the world, a minimal and
_complete_ example of how one can actually write a polymorphic pretty
printer. This _must_ be an FAQ.

Best regards,


To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: