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 discorde.inria.fr (discorde.inria.fr [192.93.2.38]) by yquem.inria.fr (Postfix) with ESMTP id E3179BC6B for ; Fri, 29 Jun 2007 20:26:09 +0200 (CEST) Received: from ipmail03.adl2.internode.on.net (ipmail03.adl2.internode.on.net [203.16.214.135]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id l5TIQ7dP011105 for ; Fri, 29 Jun 2007 20:26:09 +0200 X-IronPort-AV: E=Sophos;i="4.16,476,1175437800"; d="scan'208";a="109525369" Received: from ppp59-167-2-129.lns1.syd7.internode.on.net (HELO [192.168.1.201]) ([59.167.2.129]) by ipmail03.adl2.internode.on.net with ESMTP; 30 Jun 2007 03:56:06 +0930 Subject: Re: [Caml-list] ANN: pattern guards From: skaller To: Jeremy Yallop Cc: Caml List In-Reply-To: References: Content-Type: text/plain Date: Sat, 30 Jun 2007 04:26:02 +1000 Message-Id: <1183141562.5305.19.camel@rosella.wigram> Mime-Version: 1.0 X-Mailer: Evolution 2.10.1 Content-Transfer-Encoding: 7bit X-Miltered: at discorde with ID 46854EBF.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; 0100,:01 ocaml:01 'when':01 rewriting:01 encodings:01 sourceforge:01 wrote:01 precedence:01 caml-list:01 define:01 match:02 match:02 variables:02 variables:02 pattern:04 On Fri, 2007-06-29 at 15:19 +0100, Jeremy Yallop wrote: > I'm pleased to announce the initial release of `patterns', an OCaml > extension providing general-purposes additions to pattern matching. I want to do this: match x with | Y x with a=x and b=x | X (y,z) with a=y and b=z -> f a b This won't work at the moment for two reasons: * I assume the precedence of 'with' is the same as 'when', which is not convenient * the variables in the basic patterns don't agree The whole point of the above is to switch all the branches to normalised variables. At the moment I have to write: match x with | Y x -> f x x | X (y,z) -> f y z This is very bad, because either I duplicate lots of code, or I actually define a subroutine f .. the problem with that is that in a large match, the only place to put it is before the top of the match .. a long way from where it is required. The need for the above occurs in term rewriting systems for which there are abbreviations or redundant encodings. -- John Skaller Felix, successor to C++: http://felix.sf.net