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 GAA20107; Mon, 11 Aug 2003 06:39:49 +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 GAA24539 for ; Mon, 11 Aug 2003 06:39:48 +0200 (MET DST) Received: from mail2.tpgi.com.au (mail.tpgi.com.au [203.12.160.58]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id h7B4dkf17807 for ; Mon, 11 Aug 2003 06:39:46 +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 mail2.tpgi.com.au (8.12.9/8.12.9) with ESMTP id h7B4dctj017304; Mon, 11 Aug 2003 14:39:39 +1000 Subject: Re: [Caml-list] tpyping question From: skaller Reply-To: skaller@ozemail.com.au To: Oleg Trott Cc: caml-list@inria.fr In-Reply-To: <200308102251.57305.oleg_trott@columbia.edu> References: <1060564412.7474.11.camel@localhost.localdomain> <200308102251.57305.oleg_trott@columbia.edu> Content-Type: text/plain Message-Id: <1060576786.9476.31.camel@localhost.localdomain> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.2 (1.2.2-4) Date: 11 Aug 2003 14:39:46 +1000 Content-Transfer-Encoding: 7bit X-Kaspersky-Antivirus: Passed X-Loop: caml-list@inria.fr X-Spam: no; 0.00; ozemail:01 caml-list:01 oleg:01 inference:01 compiler:01 variants:01 int:01 coercion:01 polymorphic:01 match:02 typing:03 wrote:03 btw:03 let:04 mean:05 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Mon, 2003-08-11 at 12:51, Oleg Trott wrote: > This is indeed very odd, because the equivalent > > let f a = match a with `A -> g a | `B _ -> g a | _ -> g a > > works fine. Yes, but there are some strange things happen with polymorphic variants -- I mean sometimes you need a coercion and sometimes a double coercion, and I don't have that strong a grasp on the typing to really be sure what's a limitation of the inference engine and whats not: as a human I sometimes read 'intent' into something that the compiler doesn't :-) BTW: something I've needed is like this: type [`A of int * int | `B of int] let f x = match x with | `A (i,j) | `B i with j=0 -> .... (* ******** *) At the moment, I have to code this as: let f x = let g i j = ... in match x with | `A (i,j) -> g i j | `B i -> g i 0 delocalising the case handling code. ------------------- 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