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 VAA14742; Mon, 11 Aug 2003 21:02:28 +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 VAA16853 for ; Mon, 11 Aug 2003 21:02:27 +0200 (MET DST) Received: from summerset.crim.ca (summerset.crim.ca [132.218.1.204]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id h7BJ2Qf08639 for ; Mon, 11 Aug 2003 21:02:26 +0200 (MET DST) Received: from touffu.crim.ca (touffu.crim.ca [132.218.1.21]) by summerset.crim.ca (8.12.8/8.12.8) with ESMTP id h7BJ2Ojw007457 for ; Mon, 11 Aug 2003 15:02:25 -0400 (EDT) X-Spam-Status: No, hits=1.0 required=5.0 tests=EMAIL_ATTRIBUTION,IN_REP_TO,MISSING_HEADERS, REFERENCES,REPLY_WITH_QUOTES,USER_AGENT_MOZILLA_UA X-Spam-Level: * Received: from crim.ca ([132.218.30.230]) (authenticated user tturpin@touffu.crim.ca) by touffu.crim.ca (Kerio MailServer 5.6.5) (using TLSv1/SSLv3 with cipher RC4-MD5 (128 bits)) for caml-list@inria.fr; Mon, 11 Aug 2003 15:02:23 -0400 Message-ID: <3F37E83E.5@crim.ca> Date: Mon, 11 Aug 2003 15:02:22 -0400 From: Tiphaine Turpin User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.2) Gecko/20030227 X-Accept-Language: en-us, en MIME-Version: 1.0 CC: caml-list@inria.fr Subject: Re: [Caml-list] tpyping question References: <1060564412.7474.11.camel@localhost.localdomain> <200308102251.57305.oleg_trott@columbia.edu> <1060576786.9476.31.camel@localhost.localdomain> <3F37271A.60005@1969.ws> <1060625815.16392.8.camel@localhost.localdomain> In-Reply-To: <1060625815.16392.8.camel@localhost.localdomain> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 bug:01 faq:01 beginner's:01 beginners:01 bin:01 caml-bugs:01 ocaml:01 caml:01 handler:01 int:01 groups:01 match:02 wrote:03 btw:03 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Hello, here is another solution, but it's not better if there are many cases match x, 0 with | `A n, _ | `B, n -> g n | `C x, _ -> ... ;; skaller wrote: >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 > > ------------------- 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