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=1.3 required=5.0 tests=SPF_FAIL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id 79E42BC69 for ; Sun, 4 Mar 2007 15:25:04 +0100 (CET) Received: from ciao.gmane.org (main.gmane.org [80.91.229.2]) by concorde.inria.fr (8.13.6/8.13.6) with ESMTP id l24EP3Zi019251 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NO) for ; Sun, 4 Mar 2007 15:25:04 +0100 Received: from root by ciao.gmane.org with local (Exim 4.43) id 1HNre2-0005pN-GA for caml-list@inria.fr; Sun, 04 Mar 2007 15:25:02 +0100 Received: from hydrogene.pps.jussieu.fr ([134.157.168.1]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sun, 04 Mar 2007 15:25:02 +0100 Received: from li by hydrogene.pps.jussieu.fr with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sun, 04 Mar 2007 15:25:02 +0100 X-Injected-Via-Gmane: http://gmane.org/ To: caml-list@inria.fr From: Zheng Li Subject: Re: records with polymorphic variants? Date: Sun, 04 Mar 2007 15:22:08 +0100 Message-ID: <87k5xxjdgv.fsf@gmail.com> References: <45EA613F.3030104@generation.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Complaints-To: usenet@sea.gmane.org X-Gmane-NNTP-Posting-Host: hydrogene.pps.jussieu.fr User-Agent: Gnus/5.110006 (No Gnus v0.6) Emacs/22.0.95 (gnu/linux) Cancel-Lock: sha1:AuAVrOgtnVjGYrvRvI2xkpRD1i0= Sender: news X-Miltered: at concorde with ID 45EAD6BF.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; variants:01 polymorphism:01 polymorphic:01 polymorphic:01 writes:01 pps:01 pps:01 jussieu:01 jussieu:01 constraint:01 constraint:01 int:01 int:01 expression:02 parameter:02 Hi, Eliot Handelman writes: > type f = [ `A of int ] > > type r = { x : f } > > but then I can't do this: > > { x = `B "test" } Here you want type f polymorphic, however as the type of a record field, its polymorphism has to be reflected (bound) as type parameter in the declaration of r. I guess you want the follows # type 'a r = { x : 'a } constraint 'a = [> f] type 'a r = { x : 'a; } constraint 'a = [> f ] # {x = "test"} Characters 6-12: { x = "test"};; ^^^^^^ This expression has type string but is here used with type [> f ] # {x = `B "test"} - : [> `A of int | `B of string ] r = {x = `B "test"} HTH, :) -- Zheng Li http://www.pps.jussieu.fr/~li/