From: Andrej Bauer <Andrej.Bauer@andrej.com>
To: caml-list@inria.fr
Subject: [Caml-list] Polymorphic pretty printing
Date: Mon, 18 Oct 2004 17:42:28 +0200 [thread overview]
Message-ID: <4173E464.7030500@andrej.com> (raw)
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
next reply other threads:[~2004-10-18 15:42 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-10-18 15:42 Andrej Bauer [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4173E464.7030500@andrej.com \
--to=andrej.bauer@andrej.com \
--cc=caml-list@inria.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox