[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Alex Baretta <alex@b...> |
| Subject: | Re: [Caml-list] string_of_polymorphic |
Luca Pascali wrote: > # let a = `Hi;; > val a : [> `Hi ] = `Hi > -------------------^ I'd like to have this string > > I tried using the Obj module, but I got only segmentation faults. > I know that the Obj module has not to be used, but what I want to write > will be placed into a library with a signature like this: > > val string_of_polymorphic : [> `Dummy ] -> string Ciao Luca, I have a solution to the problem: it requires Camlp4. It is possible to build a syntax extension such that type poly = [ `Pizza | `Pie ] actually compiles down to type poly = [ `Pizza | `Pie ] let string_of_poly = function | `Pizza -> "Pizza" | `Pie -> "Pie" Let me refer you to the relevant documentation: http://caml.inria.fr/camlp4/manual/manual005.html#toc11 A similar job is done by IoXml. Take a look at it: you probably want to start out by modifying Daniel's code rather than starting from scratch. http://pauillac.inria.fr/~ddr/IoXML/ Have fun! Alex -- ********************************************************************* http://www.barettadeit.com/ Baretta DE&IT A division of Baretta SRL tel. +39 02 370 111 55 fax. +39 02 370 111 54 Our technology: The Application System/Xcaml (AS/Xcaml) <http://www.asxcaml.org/> The FreerP Project <http://www.freerp.org/>