Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: Martin Jambon <martin.jambon@ens-lyon.org>
To: Jon Harrop <jon@ffconsultancy.com>
Cc: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] Patterns that evaluate
Date: Wed, 14 Feb 2007 14:34:30 -0800 (PST)	[thread overview]
Message-ID: <Pine.LNX.4.58.0702141342340.12261@localhost> (raw)
In-Reply-To: <200702132207.33793.jon@ffconsultancy.com>

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


  parent reply	other threads:[~2007-02-14 22:35 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-02-13 22:04 Jacques Carette
2007-02-13 22:07 ` [Caml-list] " Jon Harrop
2007-02-14  0:10   ` Jacques Carette
2007-02-14 18:20   ` Edgar Friendly
2007-02-14 18:55     ` Gerd Stolpmann
2007-02-14 19:10       ` Denis Bueno
2007-02-14 19:11       ` Jacques Carette
2007-02-14 19:25         ` Gerd Stolpmann
2007-02-14 20:30           ` Edgar Friendly
2007-02-14 21:05       ` Jon Harrop
2007-02-14 21:33         ` Jacques Carette
2007-02-14 22:34   ` Martin Jambon [this message]
2007-02-15  0:26     ` Jacques Garrigue
2007-02-15  3:57       ` Jon Harrop
2007-02-15 22:43         ` Don Syme
2007-02-14 20:29 ` Nathaniel Gray
2007-02-14 21:10   ` Jacques Carette
2007-02-15  3:53     ` skaller
2007-02-15 13:41       ` Jacques Carette
2007-02-15 14:10         ` skaller
2007-02-15 20:43     ` Nathaniel Gray
2007-03-07 11:15       ` Oliver Bandel

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=Pine.LNX.4.58.0702141342340.12261@localhost \
    --to=martin.jambon@ens-lyon.org \
    --cc=caml-list@yquem.inria.fr \
    --cc=jon@ffconsultancy.com \
    /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