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 RAA25915; Tue, 10 Jun 2003 17:29:04 +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 RAA25604 for ; Tue, 10 Jun 2003 17:29:02 +0200 (MET DST) Received: from isis.lip6.fr (isis.lip6.fr [132.227.60.2]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id h5AFT2H16457 for ; Tue, 10 Jun 2003 17:29:02 +0200 (MET DST) Received: from spi.lip6.fr (spi.lip6.fr [132.227.83.193]) by isis.lip6.fr (8.12.9/jtpda-5.4+victor) with ESMTP id h5AFT1G6017880 ; Tue, 10 Jun 2003 17:29:01 +0200 X-pt: isis.lip6.fr Received: from inria.fr (doligezportable.lip6.fr [132.227.83.219]) by spi.lip6.fr (8.11.6/jtpda-5.2) with ESMTP id h5AFTUv03000 ; Tue, 10 Jun 2003 17:29:30 +0200 Date: Tue, 10 Jun 2003 17:28:57 +0200 Subject: Re: [Caml-list] polymorphic type constructor deconstructor Content-Type: text/plain; charset=US-ASCII; format=flowed Mime-Version: 1.0 (Apple Message framework v552) Cc: caml-list@inria.fr To: "Jeffrey J. Cook" From: Damien Doligez In-Reply-To: <20030606213021.GE27432@crhc.uiuc.edu> Message-Id: <4069A4E9-9B58-11D7-AB87-0003930FCE12@inria.fr> Content-Transfer-Encoding: 7bit X-Mailer: Apple Mail (2.552) X-Scanned-By: isis.lip6.fr X-Spam: no; 0.00; damien:01 caml-list:01 failwith:01 compiler:01 doligez:01 polymorphic:01 match:02 wrote:03 annoying:03 constructor:03 complain:03 let:04 cook:04 pattern:06 type:07 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Friday, June 6, 2003, at 11:30 PM, Jeffrey J. Cook wrote: > let request = REQ_do_this 5 in > let reply = Socket.client "mysocket" request in > let success = > match reply with > | REPLY_do_this x -> x > | _ -> failwith "this case shouldn't happen and is annoying" You can use patterns in the left-hand part of a let: let request = REQ_do_this 5 in let reply = Socket.client "mysocket" request in let REPLY_do_this success = reply in ... success ... The compiler will complain about a non-exhaustive pattern matching, but that's only fair. -- Damien ------------------- 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