Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: skaller <skaller@users.sourceforge.net>
To: Jeremy Yallop <jeremy.yallop@ed.ac.uk>
Cc: Caml List <caml-list@inria.fr>
Subject: Re: [Caml-list] ANN: pattern guards
Date: Sat, 30 Jun 2007 04:26:02 +1000	[thread overview]
Message-ID: <1183141562.5305.19.camel@rosella.wigram> (raw)
In-Reply-To: <Pine.LNX.4.64.0706291518250.15944@rydell.inf.ed.ac.uk>

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 <skaller at users dot sf dot net>
Felix, successor to C++: http://felix.sf.net


  reply	other threads:[~2007-06-29 18:26 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-06-29 14:19 Jeremy Yallop
2007-06-29 18:26 ` skaller [this message]
2007-06-29 18:56   ` [Caml-list] " Jeremy Yallop
2007-06-29 19:31     ` Brian Hurt
2007-06-30  4:09     ` skaller
2007-06-30  4:44       ` Arnaud Spiwack
2007-07-03  9:29         ` Jeremy Yallop

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1183141562.5305.19.camel@rosella.wigram \
    --to=skaller@users.sourceforge.net \
    --cc=caml-list@inria.fr \
    --cc=jeremy.yallop@ed.ac.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox