caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Ashish Agarwal <agarwal1975@gmail.com>
To: Martin DeMello <martindemello@gmail.com>
Cc: Jeremy Yallop <yallop@gmail.com>,
	"caml-list@inria.fr" <caml-list@inria.fr>
Subject: Re: [Caml-list] intersections of polymorphic variants
Date: Thu, 9 Feb 2017 10:15:16 -0500	[thread overview]
Message-ID: <CAMu2m2LtT6aKh0_mB1Zdctpek-6URcVJO+15a6qZFnYyhBq9aA@mail.gmail.com> (raw)
In-Reply-To: <CAFrFfuFa+WwY87vE5HjQen8Godaz0R_vur1-3+GQM4Uu3oUmTA@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 714 bytes --]

Also you might want abbreviation patterns. If your `value` type included
all `color` values, like this:

type value = [color | `Missing]

then, you could write:

let state_of_value v = match v with
  | #color as c -> Color (color_index c)
  | `Missing -> Missing


On Thu, Feb 9, 2017 at 5:03 AM, Martin DeMello <martindemello@gmail.com>
wrote:

> On Thu, Feb 9, 2017 at 1:57 AM, Jeremy Yallop <yallop@gmail.com> wrote:
>
>> >
>> > let state_of_value v = match v with
>> >   | `Red  | `Blue  | `Green -> ?????
>> >   | `Missing -> Missing
>>
>>   let state_of_value v = match v with
>>     | (`Red  | `Blue  | `Green) as c -> Color (color_index c)
>>     | `Missing -> Missing
>>
>
> perfect, thanks!
>
> martin
>

[-- Attachment #2: Type: text/html, Size: 1648 bytes --]

      reply	other threads:[~2017-02-09 15:16 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-09  9:52 Martin DeMello
2017-02-09  9:57 ` Jeremy Yallop
2017-02-09 10:03   ` Martin DeMello
2017-02-09 15:15     ` Ashish Agarwal [this message]

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=CAMu2m2LtT6aKh0_mB1Zdctpek-6URcVJO+15a6qZFnYyhBq9aA@mail.gmail.com \
    --to=agarwal1975@gmail.com \
    --cc=caml-list@inria.fr \
    --cc=martindemello@gmail.com \
    --cc=yallop@gmail.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;
as well as URLs for NNTP newsgroup(s).