caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Olivier Nicole <olivier.th.nicole@gmail.com>
To: caml-list@inria.fr
Subject: Re: [Caml-list] beginner question about pattern matching
Date: Thu, 19 Oct 2017 16:30:49 +0200	[thread overview]
Message-ID: <1111d3bb-bab0-d2e9-17cb-d1dac13d9908@gmail.com> (raw)
In-Reply-To: <CAJgjwehAOM-PgdUmNJvg6uBKoA5qT2m3rTe-09gPSgRWjcrMXw@mail.gmail.com>

Hello,

On 10/19/2017 04:29 PM, vrotaru.md@gmail.com wrote:
> Rtag ((_,_,_,_) as t4) -> t4
> 
> Will this work? Writing from the phone

No, this will complain that the Rtag constructor expects 4 arguments.
I would say that what you are trying to do is not possible, but I'm not
absolutely certain.

> 
> 
> On Thu, Oct 19, 2017, 17:24 Matej Košík <mail@matej-kosik.net
> <mailto:mail@matej-kosik.net>> wrote:
> 
>     On 10/19/2017 04:16 PM, vrotaru.md@gmail.com
>     <mailto:vrotaru.md@gmail.com> wrote:
>     > [ Rtag (_,_,_,_) as rtag] -> rtag
> 
>     That is certainly possible.
>     It is equivalent to:
> 
>       | [rtag] -> rtag
> 
>     but that's not what I am trying to do.  :-/
> 
>     Instead of the whole
> 
>       Rtag (something1, something2, something3, something4)
> 
>     I would like to bind just the 4-tuple
>     (without the Rtag label).
> 
>     >
>     >
>     > On Thu, Oct 19, 2017, 16:39 Matej Košík <mail@matej-kosik.net
>     <mailto:mail@matej-kosik.net> <mailto:mail@matej-kosik.net
>     <mailto:mail@matej-kosik.net>>> wrote:
>     >
>     >     Hi,
>     >
>     >     I am trying to do simple pattern matching of these values:
>     >   
>      https://github.com/ocaml/ocaml/blob/trunk/parsing/parsetree.mli#L145
>     >
>     >     What I would like to do is:
>     >
>     >        | [Rtag the_whole_4_tuple] ->
>     >            the_whole_4_tuple
>     >
>     >     However, when I try to do that, I am getting:
>     >
>     >       Error: The constructor Rtag expects 4 argument(s),
>     >              but is applied here to 1 argument(s)
>     >
>     >     This:
>     >
>     >         | [Rtag (f1,f2,f3,f4)] ->
>     >             f1,f2,f3,f4
>     >
>     >     of course works but (regardless of the chosen bound variable
>     names), it looks amateurish.
>     >
>     >     What's the right way to do this?
>     >     (I would like just to bind a 4-tuple and then return it)
>     >
>     >     (Apologies in advance for a stupid question.)
>     >
> 

  reply	other threads:[~2017-10-19 14:30 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-19 13:38 Matej Košík
2017-10-19 14:16 ` vrotaru.md
2017-10-19 14:24   ` Matej Košík
2017-10-19 14:29     ` vrotaru.md
2017-10-19 14:30       ` Olivier Nicole [this message]
2017-10-19 14:31     ` Alan Schmitt
2017-10-19 14:34 ` Gabriel Scherer
2017-10-19 14:40   ` Matej Košík
2017-10-19 14:44   ` vrotaru.md

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=1111d3bb-bab0-d2e9-17cb-d1dac13d9908@gmail.com \
    --to=olivier.th.nicole@gmail.com \
    --cc=caml-list@inria.fr \
    /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;
as well as URLs for NNTP newsgroup(s).