From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id SAA11856; Fri, 30 Aug 2002 18:36:05 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f 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 SAA11394 for ; Fri, 30 Aug 2002 18:36:03 +0200 (MET DST) Received: from laurelin.dementia.org ([208.167.88.73]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id g7UGRMD07485 for ; Fri, 30 Aug 2002 18:27:39 +0200 (MET DST) Received: by laurelin.dementia.org (Postfix, from userid 1001) id 7638970D2; Fri, 30 Aug 2002 12:27:16 -0400 (EDT) To: tim@fungible.com (Tim Freeman) Cc: caml-list@inria.fr Subject: Re: [Caml-list] Polymorphic variants as type parameters References: <20020830155016.90B527F63@lobus.fungible.com> From: John Prevost Date: 30 Aug 2002 12:27:16 -0400 (68.560 UMT) In-Reply-To: <20020830155016.90B527F63@lobus.fungible.com> Message-ID: <86fzww2ty3.fsf@laurelin.dementia.org> User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk >>>>> "tf" == Tim Freeman writes: tf> Here's some code that I'd like to be able to compile: type eventtype = [`VECTOR | `SCALAR | `UNIT] type +'a eventid constraint 'a = [> eventtype ] type scalar_eventid = [`SCALAR] eventid tf> Unfortunately it gives me an error: The problem is that when you say [> `X | `Y | `Z] you describe a type that contains at *least* `X, `Y, and `Z, and possibly others. This type is typical for an argument type to a function. Think of this as "greater or equal to the type [`X|`Y|`Z]". When you want a type that may contain possibly `X or `Y or `Z but nothing besides those, you should write [< `X | `Y | `Z]. This is like "less than or equal to the type [`X|`Y|`Z]". Using this I get: # type eventtype = [`VECTOR | `SCALAR | `UNIT] type +'a eventid constraint 'a = [< eventtype ] type scalar_eventid = [`SCALAR] eventid;; type eventtype = [ `VECTOR | `SCALAR | `UNIT] type +'a eventid constraint 'a = [< eventtype] type scalar_eventid = [ `SCALAR] eventid John. ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners