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 UAA03846; Mon, 11 Aug 2003 20:16:59 +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 UAA15556 for ; Mon, 11 Aug 2003 20:16:57 +0200 (MET DST) Received: from mail2.tpgi.com.au (mail.tpgi.com.au [203.12.160.58]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id h7BIGtT19088 for ; Mon, 11 Aug 2003 20:16:55 +0200 (MET DST) Received: from 203-219-225-84-syd-ts24-2600.tpgi.com.au (203-219-225-84-syd-ts24-2600.tpgi.com.au [203.219.225.84]) by mail2.tpgi.com.au (8.12.9/8.12.9) with ESMTP id h7BIGjQa011572; Tue, 12 Aug 2003 04:16:47 +1000 Subject: Re: [Caml-list] tpyping question From: skaller Reply-To: skaller@ozemail.com.au To: Karl Zilles Cc: caml-list@inria.fr In-Reply-To: <3F37271A.60005@1969.ws> References: <1060564412.7474.11.camel@localhost.localdomain> <200308102251.57305.oleg_trott@columbia.edu> <1060576786.9476.31.camel@localhost.localdomain> <3F37271A.60005@1969.ws> Content-Type: text/plain Message-Id: <1060625815.16392.8.camel@localhost.localdomain> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.2 (1.2.2-4) Date: 12 Aug 2003 04:16:55 +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 handler:01 int:01 match:02 wrote:03 btw:03 let:04 suggestion:06 i'd:06 type:07 i've:09 something:09 choices:10 shown:86 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Mon, 2003-08-11 at 15:18, Karl Zilles wrote: > skaller wrote: > > 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. > > > > Wouldn't it be more natural to write: > > let f x = > let (i,j) = match x with > | `A v -> v > | `B u -> (u,0) in > ... In reality there are 20 tags, not just the 2 shown. So I'd have to write: match x with | ..... | `A _ as y | `B _ as y -> let (i,j) = match y with `A v->v | `B u -> (u,0) in ... | ...... repeating the tags, In fact I do this sometimes, but it's also poor style repeating the tags. So I have 2 choices of poor style: repeat tags or delocalise handler, hence my suggestion, in which the handler is local and there's no repetition. ------------------- 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