Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] Polymorphic pretty printing
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Andrej Bauer <Andrej.Bauer@a...>
Subject: Re: [Caml-list] Polymorphic pretty printing
Christophe TROESTLER wrote:
> 
>> Am I supposed to rewrite half of toplevel.ml to get this working?
> 
> I am afraid that the awser is yes :(.  Let's see why:

Thanks for the hints.

I'd be willing to take a shot at writing a more flexible toplevel, one
that allows to install polymorphic pretty-printers in a sane way.

I am imagining something like this. A pretty printer may be registered
with #install_printer, as before. But we need to fiddle with the types
of printers to get things working. A printer pp for type t (where t may
be polymorphic) would have type

pp : Format.formatter -> t -> (Format.formatter -> 'a -> unit) -> unit

If you compare this with the current type, you'll notice the extra
argument of type (Format.formatter -> 'a -> unit). This is a helper
function which would be passed to pp by the toplevel. Then pp can use it
to print out any polymorphic value.

Does this sound like a sound plan? Or am I missing something? Perhaps
the ocaml developers secretly posses such a toplevel already.

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