From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id RAA10640; Mon, 18 Oct 2004 17:42:30 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id RAA10761 for ; Mon, 18 Oct 2004 17:42:29 +0200 (MET DST) Received: from haka.fmf.uni-lj.si (haka.fmf.uni-lj.si [193.2.67.18]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id i9IFgTbF020169 for ; Mon, 18 Oct 2004 17:42:29 +0200 Received: from localhost ([127.0.0.1] ident=andrej) by haka.fmf.uni-lj.si with esmtp (Exim 3.36 #1 (Debian)) id 1CJZeX-0006mW-00 for ; Mon, 18 Oct 2004 17:42:29 +0200 Message-ID: <4173E464.7030500@andrej.com> Date: Mon, 18 Oct 2004 17:42:28 +0200 From: Andrej Bauer User-Agent: Mozilla Thunderbird 0.7.3 (X11/20040830) X-Accept-Language: en-us, en MIME-Version: 1.0 To: caml-list@inria.fr Subject: [Caml-list] Polymorphic pretty printing X-Enigmail-Version: 0.85.0.0 X-Enigmail-Supports: pgp-inline, pgp-mime Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Miltered: at concorde with ID 4173E465.001 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; andrej:01 bauer:01 andrej:01 bauer:01 outcometree:01 outcometree:01 faq:01 caml:01 toplevel:01 toplevel:01 polymorphic:01 polymorphic:01 arbitrary:02 arbitrary:02 converts:03 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk 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