caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] Polymorphic pretty printing
@ 2004-10-18 15:42 Andrej Bauer
  2004-10-22 22:07 ` Christophe TROESTLER
  0 siblings, 1 reply; 8+ messages in thread
From: Andrej Bauer @ 2004-10-18 15:42 UTC (permalink / raw)
  To: caml-list

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


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2004-11-26 22:53 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-10-18 15:42 [Caml-list] Polymorphic pretty printing Andrej Bauer
2004-10-22 22:07 ` Christophe TROESTLER
2004-10-24 20:54   ` Andrej Bauer
2004-10-25  1:04     ` skaller
2004-10-25  3:02       ` David Brown
2004-10-25  7:26         ` Andrej Bauer
2004-10-25 14:45     ` Jon Harrop
2004-11-26 22:54   ` Frédéric Gava

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).