caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* Typing problem
@ 2006-03-19  1:30 Daniel Bünzli
  2006-03-19 11:21 ` [Caml-list] " Jacques Garrigue
  0 siblings, 1 reply; 3+ messages in thread
From: Daniel Bünzli @ 2006-03-19  1:30 UTC (permalink / raw)
  To: Caml list

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


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2006-03-19 14:56 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-03-19  1:30 Typing problem Daniel Bünzli
2006-03-19 11:21 ` [Caml-list] " Jacques Garrigue
2006-03-19 14:58   ` Daniel Bünzli

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).