caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* replacing Mathematica was: Polymorphic pretty printing
@ 2004-10-27 19:15 HENRIKSON, JEFFREY
  2004-10-28  5:30 ` [Caml-list] " skaller
  2004-10-28 11:25 ` Andrej Bauer
  0 siblings, 2 replies; 8+ messages in thread
From: HENRIKSON, JEFFREY @ 2004-10-27 19:15 UTC (permalink / raw)
  To: Andrej Bauer, caml-list

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 
> printf style mini-language printing have to offer compared to just
using 
> 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 = { 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

* Re: [Caml-list] replacing Mathematica was: Polymorphic pretty printing
  2004-10-27 19:15 replacing Mathematica was: Polymorphic pretty printing HENRIKSON, JEFFREY
@ 2004-10-28  5:30 ` skaller
  2004-10-28 11:25 ` Andrej Bauer
  1 sibling, 0 replies; 8+ messages in thread
From: skaller @ 2004-10-28  5:30 UTC (permalink / raw)
  To: HENRIKSON, JEFFREY; +Cc: Andrej Bauer, caml-list

On Thu, 2004-10-28 at 05:15, HENRIKSON, JEFFREY wrote:

> > I'm curious why people want to use these kinds of routines. What does 
> > printf style mini-language printing have to offer compared to just
> using 
> > plain old Ocaml functions?
> 
> Sounds like Skaller doesn't like toplevels.  Fine with me.  I like them.

I don't dislike them -- I think it is more that I'm
not using them heavily, and didn't really understand the
need for pretty printing .. I do now. 

-- 
John Skaller, mailto:skaller@users.sf.net
voice: 061-2-9660-0850, 
snail: PO BOX 401 Glebe NSW 2037 Australia
Checkout the Felix programming language http://felix.sf.net




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

* Re: replacing Mathematica was: Polymorphic pretty printing
  2004-10-27 19:15 replacing Mathematica was: Polymorphic pretty printing HENRIKSON, JEFFREY
  2004-10-28  5:30 ` [Caml-list] " skaller
@ 2004-10-28 11:25 ` Andrej Bauer
  2004-10-28 13:11   ` [Caml-list] " Christophe TROESTLER
  1 sibling, 1 reply; 8+ messages in thread
From: Andrej Bauer @ 2004-10-28 11:25 UTC (permalink / raw)
  To: caml-list

HENRIKSON, JEFFREY wrote:
>
> 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!

I do not wish to write yet another symbolic algebra system. I want to
have an enriched ocaml toplevel with ocaml as my "symbolic language".
Possibly I would use camlp4 to enrich syntax with notation for
finite sets.

Perhaps one day I would want to look at something like FreshML or
what Aleksandar Nanevski from CMU has been doing for his Ph.D. to get
some "symbolic" into ocaml.

But I definitely do not want to have a rewrite system. The world has seen
enough poorly designed "languages" for symbolic manipulation that are little
more than confused combinations of rewrite systems and BASIC.

Thanks for pointing to the MIT derivative algebra implementation. I will
have a look at it. My idea of derivation was rather that the differential
operator D is an operator on a suitable algebra. With rich enough types
in my programming language, it should be possible to implement D as an
honest function--no funny notation needed.

Best regards,

Andrej


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

* Re: [Caml-list] Re: replacing Mathematica was: Polymorphic pretty printing
  2004-10-28 11:25 ` Andrej Bauer
@ 2004-10-28 13:11   ` Christophe TROESTLER
  2004-10-28 20:45     ` Andrej Bauer
  2004-10-28 21:44     ` Jon Harrop
  0 siblings, 2 replies; 8+ messages in thread
From: Christophe TROESTLER @ 2004-10-28 13:11 UTC (permalink / raw)
  To: Andrej.Bauer; +Cc: caml-list

On Thu, 28 Oct 2004, Andrej Bauer <Andrej.Bauer@andrej.com> wrote:
> 
> HENRIKSON, JEFFREY wrote:
> >
> > [...] derivative notation right!
> 
> [...] would use camlp4 to enrich syntax with notation for finite
> sets.

IMHO, the main "annoyance" with that goal is notational: there will be
many uses of "+" for example and each of these will need its own
notation.  While I am not bothered by the two "+." and "+", this can
become heavy when one manipulates lots of different structures
(vectors, matrices, polynomials, groups,...).  GCaml will be great for
this.

About the original thread, "polymorphic pretty printing", it would be
nice if folks at INRIA could give indications on what they think the
better solution is -- it would be nice if it could be made independent
of possible changes in the toplevel code.

ChriS


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

* Re: [Caml-list] Re: replacing Mathematica was: Polymorphic pretty printing
  2004-10-28 13:11   ` [Caml-list] " Christophe TROESTLER
@ 2004-10-28 20:45     ` Andrej Bauer
  2004-10-29 13:01       ` Christophe TROESTLER
  2004-10-28 21:44     ` Jon Harrop
  1 sibling, 1 reply; 8+ messages in thread
From: Andrej Bauer @ 2004-10-28 20:45 UTC (permalink / raw)
  To: Christophe TROESTLER; +Cc: caml-list

Christophe TROESTLER wrote:
> 
> IMHO, the main "annoyance" with that goal is notational: there will be
> many uses of "+" for example and each of these will need its own
> notation.  While I am not bothered by the two "+." and "+", this can
> become heavy when one manipulates lots of different structures
> (vectors, matrices, polynomials, groups,...).  GCaml will be great for
> this.

I think you just convencied me to use Haskell and its type classes.
Seriously, I wonder if a purely functional language might not be better
for my purposes.

> About the original thread, "polymorphic pretty printing", it would be
> nice if folks at INRIA could give indications on what they think the
> better solution is -- it would be nice if it could be made independent
> of possible changes in the toplevel code.

Yes, what to the makers of ocaml say? I am afraid there is no way to
avoid dependence on toplevel code, since the pretty printer must know
something about the representation of types and values.

But that's not my worry anymore. I am off to haskell, Bye bye.

Andrej


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

* Re: [Caml-list] Re: replacing Mathematica was: Polymorphic pretty printing
  2004-10-28 13:11   ` [Caml-list] " Christophe TROESTLER
  2004-10-28 20:45     ` Andrej Bauer
@ 2004-10-28 21:44     ` Jon Harrop
  2004-10-29 13:11       ` Christophe TROESTLER
  1 sibling, 1 reply; 8+ messages in thread
From: Jon Harrop @ 2004-10-28 21:44 UTC (permalink / raw)
  To: caml-list

On Thursday 28 October 2004 14:11, Christophe TROESTLER wrote:
> IMHO, the main "annoyance" with that goal is notational: there will be
> many uses of "+" for example and each of these will need its own
> notation.  While I am not bothered by the two "+." and "+", this can
> become heavy when one manipulates lots of different structures
> (vectors, matrices, polynomials, groups,...).  GCaml will be great for
> this.

Yes, OCaml is not well suited to implementing conventional mathematical 
notation because of operator overloading.

However, in GCaml, do the different definitions (e.g. "+" : int -> int -> int 
| float -> float -> float) have to be specified at the same time (i.e. in the 
"+" function)? If so, then GCaml is also ill suited...

Cheers,
Jon.


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

* Re: [Caml-list] Re: replacing Mathematica was: Polymorphic pretty printing
  2004-10-28 20:45     ` Andrej Bauer
@ 2004-10-29 13:01       ` Christophe TROESTLER
  0 siblings, 0 replies; 8+ messages in thread
From: Christophe TROESTLER @ 2004-10-29 13:01 UTC (permalink / raw)
  To: Andrej.Bauer; +Cc: caml-list

On Thu, 28 Oct 2004, Andrej Bauer <Andrej.Bauer@andrej.com> wrote:
> 
> Christophe TROESTLER wrote:
> > 
> > About the original thread, "polymorphic pretty printing", it would be
> > nice if folks at INRIA could give indications on what they think the
> > better solution is -- it would be nice if it could be made independent
> > of possible changes in the toplevel code.
> 
> [...] the pretty printer must know something about the
> representation of types and values.

That's the purpose of Ourcometree.  The thing one would like to avoid
is dependence on the default pretty printing function -- OCaml
implementers may want to change it and we should not have to worry! :)

ChriS


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

* Re: [Caml-list] Re: replacing Mathematica was: Polymorphic pretty printing
  2004-10-28 21:44     ` Jon Harrop
@ 2004-10-29 13:11       ` Christophe TROESTLER
  0 siblings, 0 replies; 8+ messages in thread
From: Christophe TROESTLER @ 2004-10-29 13:11 UTC (permalink / raw)
  To: jon; +Cc: caml-list

On Thu, 28 Oct 2004, Jon Harrop <jon@jdh30.plus.com> wrote:
> 
> However, in GCaml, do the different definitions (e.g. "+" : int ->
> int -> int | float -> float -> float) have to be specified at the
> same time (i.e. in the "+" function)? If so, then GCaml is also ill
> suited...

The future of GCaml is not clear but I hope that "additions" to a
generic definitions.  Maybe with

generic (+) =
| float -> float -> float => (+.)
| $a -> $a -> $a => (+) (* old + *)

ChriS


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

end of thread, other threads:[~2004-10-29 13:13 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-10-27 19:15 replacing Mathematica was: Polymorphic pretty printing HENRIKSON, JEFFREY
2004-10-28  5:30 ` [Caml-list] " skaller
2004-10-28 11:25 ` Andrej Bauer
2004-10-28 13:11   ` [Caml-list] " Christophe TROESTLER
2004-10-28 20:45     ` Andrej Bauer
2004-10-29 13:01       ` Christophe TROESTLER
2004-10-28 21:44     ` Jon Harrop
2004-10-29 13:11       ` Christophe TROESTLER

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).