From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id 10851BC0A for ; Wed, 14 Feb 2007 23:35:36 +0100 (CET) Received: from out4.smtp.messagingengine.com (out4.smtp.messagingengine.com [66.111.4.28]) by concorde.inria.fr (8.13.6/8.13.6) with ESMTP id l1EMZZX7013544 for ; Wed, 14 Feb 2007 23:35:35 +0100 Received: from out1.internal (unknown [10.202.2.149]) by out1.messagingengine.com (Postfix) with ESMTP id 8613B1ABD74; Wed, 14 Feb 2007 17:35:32 -0500 (EST) Received: from heartbeat1.messagingengine.com ([10.202.2.160]) by out1.internal (MEProxy); Wed, 14 Feb 2007 17:35:32 -0500 X-Sasl-enc: IyskAuwD3NouN9UFLwMZp0o/uSrGT27uhWNp+n6plm+B 1171492532 Received: from [172.16.112.115] (burnham.ljcrf.edu [192.231.106.2]) by mail.messagingengine.com (Postfix) with ESMTP id F38A929389; Wed, 14 Feb 2007 17:35:31 -0500 (EST) Date: Wed, 14 Feb 2007 14:34:30 -0800 (PST) From: Martin Jambon X-X-Sender: martin@localhost To: Jon Harrop Cc: caml-list@yquem.inria.fr Subject: Re: [Caml-list] Patterns that evaluate In-Reply-To: <200702132207.33793.jon@ffconsultancy.com> Message-ID: References: <45D23608.4030104@mcmaster.ca> <200702132207.33793.jon@ffconsultancy.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-j-chkmail-Score: MSGID : 45D38EB7.000 on concorde : j-chkmail score : X : 0/20 1 0.000 -> 1 X-Miltered: at concorde with ID 45D38EB7.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; ens-lyon:01 ocaml:01 ocaml's:01 bug:01 afaik:01 ocaml's:01 syntax:01 msdn:01 dsyme:01 vice-versa:01 2007,:98 wrote:01 wrote:01 imho:01 caml-list:01 On Tue, 13 Feb 2007, Jon Harrop wrote: > On Tuesday 13 February 2007 22:04, Jacques Carette wrote: > > I recently wrote some ocaml code which "worked", but not as I > > intended... The test cases I tried worked, but I should have tested > > harder. Apparently I was under the mistaken impression that OCaml's > > pattern-matching was more "first class"! So I wrote (in part): > > > > let buildsimp cast e f1 f2 = fun e1 -> fun e2 -> match (e1,e2) with > > > > | ({st = Some e}, _) -> e2 > > > > and I expected it to work. Only a code review by a colleague 'found' > > this bug in my code. > > > > Question: would it be a difficult extension? This seemed so "natural", > > I just "used" the feature before it was quite there yet ;-). > > F# just introduced active patterns, which does what you want AFAIK. Of course, > you must disambiguate that from the OCaml's current interpretation of the > above (binding "e"). That's funny, I posted a syntax extension that does that one week ago, but I didn't know it was already implemented in F#. http://caml.inria.fr/pub/ml-archives/caml-list/2007/02/e397c716c448a0aeff92b7af709bb1b4.en.html http://blogs.msdn.com/dsyme/archive/2006/08/16/ActivePatterns.aspx "Active patterns" seems to be another name for "simple views" or vice-versa. It converged to an extremely similar solution, so it must be a good one :-) It doesn't solve the original problem though, which IMHO is better solved with a standard "when" guard as mentioned earlier. Martin -- Martin Jambon http://martin.jambon.free.fr