Browse thread
[Caml-list] Polymorphic pretty printing
- Andrej Bauer
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ 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
http://caml.inria.fr/archives/200201/msg00234.html
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 toplevel.ml 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,
Andrej
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners