Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: Martin DeMello <martindemello@gmail.com>
To: "caml-list@inria.fr" <caml-list@inria.fr>
Subject: [Caml-list] intersections of polymorphic variants
Date: Thu, 9 Feb 2017 01:52:26 -0800	[thread overview]
Message-ID: <CAFrFfuFna+7-sSH2nqy5n+bDYPeCgSeK-RrzaTQYm7CrmEE1zw@mail.gmail.com> (raw)

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

In the following code:

type color = [`Red | `Blue | `Green | `Black | `White]

let color_index c = match c with
  | `Red -> 1
  | `Blue -> 2
  | `Green -> 3
  | `Black -> 4
  | `White -> 5

type value = [`Red | `Blue | `Green | `Missing]

type state = Color of int | Missing

let state_of_value v = match v with
  | `Red -> Color (color_index `Red)
  | `Blue -> Color (color_index `Blue)
  | `Green -> Color (color_index `Green)
  | `Missing -> Missing

is there any way to write the last function as

let state_of_value v = match v with
  | `Red  | `Blue  | `Green -> ?????
  | `Missing -> Missing

martin

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

             reply	other threads:[~2017-02-09  9:52 UTC|newest]

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

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=CAFrFfuFna+7-sSH2nqy5n+bDYPeCgSeK-RrzaTQYm7CrmEE1zw@mail.gmail.com \
    --to=martindemello@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