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 DAA05718; Mon, 11 Aug 2003 03:13:32 +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 DAA17721 for ; Mon, 11 Aug 2003 03:13:31 +0200 (MET DST) Received: from mail3.tpgi.com.au (mail.tpgi.com.au [203.12.160.59]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id h7B1DTf08772 for ; Mon, 11 Aug 2003 03:13:29 +0200 (MET DST) Received: from 203-213-83-171-syd-ts15-2600.tpgi.com.au (203-213-83-171-syd-ts15-2600.tpgi.com.au [203.213.83.171]) by mail3.tpgi.com.au (8.11.6/8.11.6) with ESMTP id h7B1DP428447 for ; Mon, 11 Aug 2003 11:13:26 +1000 Subject: [Caml-list] tpyping question From: skaller Reply-To: skaller@ozemail.com.au To: caml-list@inria.fr Content-Type: text/plain Message-Id: <1060564412.7474.11.camel@localhost.localdomain> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.2 (1.2.2-4) Date: 11 Aug 2003 11:13:32 +1000 Content-Transfer-Encoding: 7bit X-Loop: caml-list@inria.fr X-Spam: no; 0.00; ozemail:01 compiles:01 annotations:01 int:01 coercion:01 variant:02 match:02 float:02 argument:03 messy:03 let:04 infered:05 body:93 type:07 annotation:07 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk type x = [`A | `B of int | `V of float];; let g (a:x) = a;; let f a = match a with | `A -> g a (* | `B _ *) | _ -> g a;; Compiles fine, but gives an error if the comments are removed. File "xx.ml", line 4, characters 10-11: This expression has type [< `A | `B of 'a ] but is here used with type x = [ `A | `B of int | `V of float ] The first variant type does not allow tag(s) `V I can fix this with a coercion/annotation: | (`A:x) -> g a but that's a bit messy. Of course an annotation on the argument doesn't work (since such annotations are only consulted *after* the body type is infered). Is there a better way to do this? ------------------- 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