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 3CF69BB81 for ; Wed, 5 Jan 2005 19:17:10 +0100 (CET) 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 j05IH95D009395 for ; Wed, 5 Jan 2005 19:17:09 +0100 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 TAA19154 for ; Wed, 5 Jan 2005 19:17:09 +0100 (MET) Received: from alex.barettalocal.com (h213-255-109-130.albacom.net [213.255.109.130] (may be forged)) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id j05IH8aA019555 for ; Wed, 5 Jan 2005 19:17:09 +0100 Received: from [127.0.0.1] (localhost.localdomain [127.0.0.1]) by alex.barettalocal.com (Postfix) with ESMTP id 41EE82BAA3D; Wed, 5 Jan 2005 19:17:09 +0100 (CET) Message-ID: <41DC2F24.1020700@barettadeit.com> Date: Wed, 05 Jan 2005 19:17:08 +0100 From: Alex Baretta User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.3) Gecko/20041007 Debian/1.7.3-5 X-Accept-Language: it, en-us, en MIME-Version: 1.0 To: Luca Pascali Cc: caml-list@inria.fr Subject: Re: [Caml-list] string_of_polymorphic References: <41D915E0.4030701@yahoo.it> In-Reply-To: <41D915E0.4030701@yahoo.it> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Miltered: at nez-perce with ID 41DC2F25.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at concorde with ID 41DC2F24.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; baretta:01 caml-list:01 wrote:01 val:01 val:01 syntax:01 ioxml:01 daniel's:01 ioxml:01 baretta:01 polymorphic:01 polymorphic:01 compiles:01 poly:01 poly:01 X-Spam-Checker-Version: SpamAssassin 3.0.0 (2004-09-13) on yquem.inria.fr X-Spam-Status: No, score=0.1 required=5.0 tests=FORGED_RCVD_HELO autolearn=disabled version=3.0.0 X-Spam-Level: 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) The FreerP Project