From mboxrd@z Thu Jan 1 00:00:00 1970 X-Sympa-To: caml-list@inria.fr Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by walapai.inria.fr (8.13.6/8.13.6) with ESMTP id q47BbkDA002303 for ; Mon, 7 May 2012 13:37:46 +0200 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AsMBAAGzp0/RVdy2kmdsb2JhbABEFoIwpw8BiToqAQEBAQkLCwcSKYIMAQEBAgEBEgIsARsYBQEDAQsGBQQHOyIBEQEFARwGEyKHXQEDBgULnB4JA4wkgnOEPgoZJwUIV4h2AQULkRQElX6BEY1RPYQO X-IronPort-AV: E=Sophos;i="4.75,543,1330902000"; d="scan'208";a="142821298" Received: from mail-vc0-f182.google.com (HELO mail-vx0-f182.google.com) ([209.85.220.182]) by mail4-smtp-sop.national.inria.fr with ESMTP/TLS/RC4-SHA; 07 May 2012 13:37:40 +0200 Received: by vcbfy7 with SMTP id fy7so419736vcb.27 for ; Mon, 07 May 2012 04:37:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=adIhWFSQNXtlqOdn3Qct4ogdkK3ZByi01a0JxSrk/d4=; b=esvSax+XUblI6AKH1Ew6hWsG55V7pT/W6bfOeN8Til1f2NroExRQawJYcmJ3pZbchU tun7BZmUgC8I5MbrT1/qJh/vODDRdsiSvhfU6Q+TzTGHJeHU88BMAiGSbr9DC45kyStu DgUTRrxakFI5jlz7mVKon908xDUOK4yUIvUqQrwtQxZCzi/eHD8Hbbq/gm23/vPs3O7D kBvZhZcZG94gN1+XOHpjkpSjh3Fudw4oUtE4HcSRhiBflF+ld+WKS+dviiDLi9belX34 ISvYsDuFwmKTBCUywNk5NBst1hglulyP2p4vsEXX0g37pplyoEgFR0n/pH3+w3ZFRoP3 ykuw== Received: by 10.52.67.19 with SMTP id j19mr7277827vdt.46.1336390659809; Mon, 07 May 2012 04:37:39 -0700 (PDT) MIME-Version: 1.0 Received: by 10.52.188.1 with HTTP; Mon, 7 May 2012 04:37:19 -0700 (PDT) In-Reply-To: <1336383633.2612.YahooMailRC@web180006.mail.gq1.yahoo.com> References: <1336383633.2612.YahooMailRC@web180006.mail.gq1.yahoo.com> From: Philippe Veber Date: Mon, 7 May 2012 13:37:19 +0200 Message-ID: To: Dan Bensen Cc: caml-list@inria.fr Content-Type: multipart/alternative; boundary=20cf307f3a468f201004bf70b277 X-Validation-by: philippe.veber@gmail.com Subject: Re: [Caml-list] extending user-defined polymorphic variant types --20cf307f3a468f201004bf70b277 Content-Type: text/plain; charset=ISO-8859-1 Hi Dan, I'm afraid you can't. If you want to write unions of polymorphic variant types, they have to be concrete and not abstract. See Romain Bardou's work on this: http://romain.bardou.fr/papers/stage2006p.pdf Or, if you can read french: www.math.nagoya-u.ac.jp/~garrigue/papers/index.html (see Unions de variants polymorphes abstraits). Cheers, Philippe. 2012/5/7 Dan Bensen > > I'm trying to write a functor that extends a user-supplied polymorphic > variant type (PVT). How do you declare the user's type in the signature > for the argument to the functor without locking in the individual variant > definitions? > The code below (in revised syntax) generates an error message that says > the type isn't a PVT. > > code: > > > module type Reader = sig type ast; end; > > > > module Make (Read: Reader) = struct > > type ast = [= Read.ast | `Lid of string]; > > end; > > message: > > > Error: The type Read.ast is not a polymorphic variant type > > How do you make ast a PVT while allowing the user to > specify the variants? > --20cf307f3a468f201004bf70b277 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Hi Dan,

I'm afraid you can't. If you want to write unions of= polymorphic variant types, they have to be concrete and not abstract. See = Romain Bardou's work on this:

http://romain.bardou.fr/papers/stage2006p.pdf
Or, if you can read french:

www.math.nagoya-u.ac.jp/~garrigue/papers= /index.html

(see Unions de variants polymorphes abstraits).

Cheers,
=A0 Philippe.



2012= /5/7 Dan Bensen <danbensen@att.net>

I'm trying to write a functor that extends= a user-supplied polymorphic
variant type (PVT).=A0 How do you declare = the user's type in the signature
for the argument to the functor without locking in the individual variant <= br>definitions?=A0
The code below (in revised syntax) generates an erro= r message that says
the type isn't a PVT.

code:

> m= odule type Reader =3D sig type ast; end;
>
> module Make (Read: Reader) =3D struct
> =A0 type ast =3D= [=3D Read.ast | `Lid of string];
> end;

message:

> Error: The type Read.ast is not a polymorphic variant type

= How do you make ast a PVT while allowing the user to
specify the varian= ts?

--20cf307f3a468f201004bf70b277--