From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by yquem.inria.fr (Postfix) with ESMTP id A98BABC3F for ; Wed, 27 Oct 2004 21:15:39 +0200 (CEST) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id i9RJFdn8028884 for ; Wed, 27 Oct 2004 21:15:39 +0200 Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id VAA29090 for ; Wed, 27 Oct 2004 21:15:38 +0200 (MET DST) Received: from rdcmx1.safeco.com (rdcmx1.safeco.com [12.144.132.31]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id i9RJFaVY028868 for ; Wed, 27 Oct 2004 21:15:38 +0200 Received: from psmrdcex03.psm.pin.safeco.com (Not Verified[12.144.134.38]) by rdcmx1.safeco.com id ; Wed, 27 Oct 2004 12:15:35 -0700 Received: from safeco.com ([168.147.237.20]) by psmrdcex03.psm.pin.safeco.com with Microsoft SMTPSVC(5.0.2195.6713); Wed, 27 Oct 2004 12:15:35 -0700 X-MimeOLE: Produced By Microsoft Exchange V6.0.6487.1 MIME-Version: 1.0 Subject: replacing Mathematica was: Polymorphic pretty printing Date: Wed, 27 Oct 2004 12:15:35 -0700 Message-ID: <9410EC84C0872141B27A2726613EF45D02A52DE0@psmrdcex01.psm.pin.safeco.com> Thread-Topic: replacing Mathematica was: Polymorphic pretty printing Thread-Index: AcS1KeTKmoDs6m1jS5K4TyTnJ1z/HAHKh89Q From: "HENRIKSON, JEFFREY" To: "Andrej Bauer" , X-OriginalArrivalTime: 27 Oct 2004 19:15:35.0625 (UTC) FILETIME=[561FC390:01C4BC59] content-class: urn:content-classes:message Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable X-Miltered: at nez-perce with ID 417FF3DB.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at nez-perce with ID 417FF3D8.001 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; replacing:01 henrikson:01 toplevel:01 toplevel:01 hashes:01 printf:01 ocaml:01 toplevels:01 symbolic:01 derivative:01 notation:01 derivative:01 algebra:01 notation:01 replacing:01 X-Spam-Checker-Version: SpamAssassin 3.0.0 (2004-09-13) on yquem.inria.fr X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.0.0 X-Spam-Level: I agree that polymorphic toplevel printing is a worthy project. I posted on this last month or two and got a "here's how you can keep it polymorphic until you actually plug it into the toplevel" answer. All I wanted to be able to do was print out my double ended queue type. :-( Many times I've also wanted to print hashes. > I'm curious why people want to use these kinds of routines. What does=20 > printf style mini-language printing have to offer compared to just using=20 > plain old Ocaml functions? Sounds like Skaller doesn't like toplevels. Fine with me. I like them. I would also like to see a totally native code toplevel someday, though I understand there are partial solutions and the real solution has big obstacles. > (the evil plan is to replace Mathematica) On the subject of evil plan, I would like to say: if you write yet another symbolic package, make sure to get the derivative notation right! There is an excellent MIT scheme implementation of a derivative algebra. Sussman (of Structure and Interpretation of Computer Programs fame) did it for a class he teaches in Lagrangian mechanics. Everybody has seen the goofy "d by d(q dot)" notation in the traditional physicist's presentation of Lagrangians. Ten hours of getting your head around broken notation to one hour of acutal understanding. Well they took the derivative notation in Spivak "Calculus on Manifolds" and mechanised it. (Spivak points out even the chain rule breaks Leibnitz notation and proposes a solution.) Now with the mechanized version: - The notation they write into scheme to run their simulations is concise enough to also serve the function of blackboard presentation. - If f : R^3 x R^3, then Df is maps R^3 to 3x3 matrix space, right? So what is D(Df)? Easy in their system. - The up tuple/ down tuple notation they use to implement this subsumes the usual tensor notation. - The chain rule and other nice things work in every dimensionality. What's more, they recently published what used to be hard to find course notes, so now there is a "Structure and Interpretation of Classical Mechanics." You can buy it on Amazon and/or read it on the web: http://mitpress.mit.edu/SICM/ Also on the subject of evil plan, I'd like to point out some other useful things which I have considered could be replacing: - SAS - SQL sans concurrency, for analysis only Basically, the main difference being whether you like your analysis database to be ordered or unordered. I need either solution to work out-of-core so I can have data bigger than RAM. I would like the toplevel printing to be extended to "here's a GUI widget which gets returned. You can double click it to see the table inside." Like how the LyX TeX frontend does footnotes/references. This is probably a separate application with a toplevel embedded. Is there any public interface to grab the toplevel, put in objects, and get out values? What about can I get out types in MLast trees? Scan the top environment so I can do identifier completion and searching? Does camlp4 interface just by text filtering, reproducing the entire syntactical environment by itself, or does it do something more intertwined? (I don't see how polymorphic printing has to do with this directly, just how useful extending the notion of toplevel could be.) Cheers, Jeff Henrikson -----Original Message----- From: owner-caml-list@pauillac.inria.fr [mailto:owner-caml-list@pauillac.inria.fr] On Behalf Of Andrej Bauer Sent: Monday, October 18, 2004 8:42 AM To: caml-list@inria.fr 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 =3D { elements : 'a list } I want a value of this type to print out as {a, b, c, ... d} instead of {elements =3D [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