[
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: | 2006-03-19 (01:29) |
From: | Daniel_Bünzli <daniel.buenzli@e...> |
Subject: | Typing problem |
Hello, I would like to define the following types. > type u = [ `U1 | `U2 ] > > type 'a t = [`A of 'a | `B of ([`U1 ] as 'a) ] constraint 'a = [< u ] t's parameter is used to statically express constraints in other parts of the code. My problem is that the constraint on 'a is downgraded to [`U1] while I would like to be able to write > let param : 'a t -> 'a = function (`A v | `B v) -> v and get the following typing behaviour. > let v = param (`A `U1) (* should type *) > let v = param (`A `U2) (* should type *) > let v = param (`B `U1) (* should type *) > let v = param (`B `U2) (* should not type *) Is it possible to express that in ocaml's type system ? Regards, Daniel