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 EAA20634; Mon, 11 Aug 2003 04:53:04 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f 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 EAA32018 for ; Mon, 11 Aug 2003 04:53:03 +0200 (MET DST) Received: from marionberry.cc.columbia.edu (marionberry.cc.columbia.edu [128.59.59.100]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id h7B2r2T20446 for ; Mon, 11 Aug 2003 04:53:02 +0200 (MET DST) Received: from tw304h3.cpmc.columbia.edu (tw304h3.cpmc.columbia.edu [156.111.84.180]) (user=ot14 mech=LOGIN bits=0) by marionberry.cc.columbia.edu (8.12.8p1/8.12.8) with ESMTP id h7B2r0Jm020594 (version=TLSv1/SSLv3 cipher=RC4-MD5 bits=128 verify=NOT); Sun, 10 Aug 2003 22:53:00 -0400 (EDT) From: Oleg Trott To: skaller@ozemail.com.au, caml-list@inria.fr Subject: Re: [Caml-list] tpyping question Date: Sun, 10 Aug 2003 22:51:56 -0400 User-Agent: KMail/1.5.3 References: <1060564412.7474.11.camel@localhost.localdomain> In-Reply-To: <1060564412.7474.11.camel@localhost.localdomain> MIME-Version: 1.0 Content-Type: text/plain; charset="koi8-r" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200308102251.57305.oleg_trott@columbia.edu> X-No-Spam-Score: Local X-Scanned-By: MIMEDefang 2.35 X-Loop: caml-list@inria.fr X-Spam: no; 0.00; oleg:01 caml-list:01 compiles:01 annotations:01 int:01 coercion:01 variant:02 match:02 float:02 wrote:03 argument:03 messy:03 let:04 equivalent:05 infered:05 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Sunday 10 August 2003 09:13 pm, skaller wrote: > 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? This is indeed very odd, because the equivalent let f a = match a with `A -> g a | `B _ -> g a | _ -> g a works fine. -- Oleg Trott ------------------- 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