From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by yquem.inria.fr (Postfix) with ESMTP id 3A370BBBB for ; Sun, 19 Mar 2006 02:29:19 +0100 (CET) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id k2J1TInC030365 for ; Sun, 19 Mar 2006 02:29:18 +0100 Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id CAA15742 for ; Sun, 19 Mar 2006 02:29:18 +0100 (MET) Received: from mail18.bluewin.ch (mail18.bluewin.ch [195.186.19.64]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id k2J1SwDU030359 for ; Sun, 19 Mar 2006 02:29:18 +0100 Received: from [10.0.1.2] (81.62.64.133) by mail18.bluewin.ch (Bluewin 7.2.071) id 43E4A16500ADE68E for caml-list@inria.fr; Sun, 19 Mar 2006 01:28:56 +0000 Mime-Version: 1.0 (Apple Message framework v746.3) Content-Transfer-Encoding: 7bit Message-Id: Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed To: Caml list From: =?ISO-8859-1?Q?Daniel_B=FCnzli?= Subject: Typing problem Date: Sun, 19 Mar 2006 02:30:14 +0100 X-Mailer: Apple Mail (2.746.3) X-Miltered: at nez-perce with ID 441CB3EE.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at nez-perce with ID 441CB3DA.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; bunzli:01 buenzli:01 epfl:01 statically:01 ocaml's:01 typing:01 typing:01 behaviour:01 define:01 constraint:01 constraint:01 parameter:02 types:02 constraints:03 let:03 X-Spam-Checker-Version: SpamAssassin 3.0.3 (2005-04-27) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.0.3 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