[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: | 2002-08-30 (16:36) |
From: | John Prevost <j.prevost@c...> |
Subject: | Re: [Caml-list] Polymorphic variants as type parameters |
>>>>> "tf" == Tim Freeman <tim@fungible.com> 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