From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.4 required=5.0 tests=AWL autolearn=disabled version=3.1.3 Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by yquem.inria.fr (Postfix) with ESMTP id B05B6BB84 for ; Thu, 9 Oct 2008 09:23:52 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AhsEAPdN7UjAXQIniGdsb2JhbACMDIdJAQEBFSKiLIdzgWo X-IronPort-AV: E=Sophos;i="4.33,382,1220220000"; d="asc'?scan'208";a="30071390" Received: from concorde.inria.fr ([192.93.2.39]) by mail4-smtp-sop.national.inria.fr with ESMTP; 09 Oct 2008 09:23:51 +0200 Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by concorde.inria.fr (8.13.6/8.13.6) with ESMTP id m997NgKu031891 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=OK) for ; Thu, 9 Oct 2008 09:23:51 +0200 X-IronPort-AV: E=Sophos;i="4.33,382,1220220000"; d="asc'?scan'208";a="15824816" Received: from peray.inria.fr (HELO ausone.inria.fr) ([128.93.8.98]) by mail2-relais-roc.national.inria.fr with SMTP; 09 Oct 2008 09:23:51 +0200 Received: by ausone.inria.fr (sSMTP sendmail emulation); Thu, _d Oct 2008 09:23:06 +0200 From: "Nicolas Pouillard" Cc: caml-list Subject: Re: [Caml-list] conjunctive type in polymorphic variants To: Conglun Yao References: In-Reply-To: Date: Thu, 09 Oct 2008 09:22:58 +0200 Message-Id: <1223536837-sup-6068@ausone.inria.fr> User-Agent: Sup/git Content-Type: multipart/signed; protocol="application/pgp-signature"; boundary="=-1223536986-27331-50294-6113-7-="; micalg="pgp-sha1" MIME-Version: 1.0 X-Miltered: at concorde with ID 48EDB17E.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; conjunctive:01 variants:01 camlp:01 conjunctive:01 compiler:01 ocaml:01 ocaml-:01 typetexp:01 stl:01 stl:01 ptyp:01 toploop:01 camlp:01 nodes:01 nodes:01 X-Attachments: cset="UTF-8" type="application/pgp-signature" name="signature.asc" name="signature.asc" --=-1223536986-27331-50294-6113-7-= Content-Type: text/plain; charset=UTF-8 Excerpts from Conglun Yao's message of Thu Oct 09 06:15:16 +0200 2008: > Hi all, > > I have just met a strange problem (it might have already been > answered, but I can't find the it) while using camlp4 to generate a > polymorphic type like: > > type t = [ `A of int * int | `B of string ] > > error msg "The present constructor A has a conjunctive type" is thrown > by the compiler. > > I followed the ocaml source code, found in ocaml-3.10.2/typing/typetexp.ml > Line 290, it does the following check in add_field function: > if List.length stl > 1 || c && stl <> [] then > raise(Error(styp.ptyp_loc, Present_has_conjunction l)); > > Sorry, I can't fully understand the source code, but it seems we can > only define a polymorphic variant with only one additional type > declaration, like > `A of int or `A of (int * int) > rather than `A of int * int Right. > It looks wired, as we can directly define > type t = [ `A of int * int | `B of string ] in toploop or a *.ml file. I think there is some syntactic thing to make it equal to `A of (int * int) in this case since `A of int * int does not make sense. > Or I have some mis-understanding in this part. In your camlp4 code you have to add tuple nodes to wrap star nodes: <:ctyp< $tup:t$ >> Best regards, -- Nicolas Pouillard aka Ertai --=-1223536986-27331-50294-6113-7-= Content-Disposition: attachment; filename="signature.asc" Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.8 (Darwin) iEYEARECAAYFAkjtsVIACgkQj+FCNw9dwLmY6gCfbGraa+unIGk/vQx8lKuxMJyA D7cAnRRycxvfDaK0IsbjdTwCjSQHd7vI =Zxe9 -----END PGP SIGNATURE----- gpg: Invalid passphrase; please try again ... --=-1223536986-27331-50294-6113-7-=--