caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Alex Baretta <alex@barettadeit.com>
To: Luca Pascali <pasckosky2000@yahoo.it>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] string_of_polymorphic
Date: Wed, 05 Jan 2005 19:17:08 +0100	[thread overview]
Message-ID: <41DC2F24.1020700@barettadeit.com> (raw)
In-Reply-To: <41D915E0.4030701@yahoo.it>

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/>


      parent reply	other threads:[~2005-01-05 18:17 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-01-03  9:52 string_of_polymorphic Luca Pascali
2005-01-03 10:18 ` [Caml-list] string_of_polymorphic Jon Harrop
2005-01-03 11:01   ` Luca Pascali
     [not found]   ` <41D9211D.7060003@yahoo.it>
     [not found]     ` <200501031100.27306.jon@jdh30.plus.com>
2005-01-03 11:06       ` Luca Pascali
2005-01-03 16:27 ` pad
2005-01-05 18:17 ` Alex Baretta [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=41DC2F24.1020700@barettadeit.com \
    --to=alex@barettadeit.com \
    --cc=caml-list@inria.fr \
    --cc=pasckosky2000@yahoo.it \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).