From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@sympa.inria.fr Delivered-To: caml-list@sympa.inria.fr Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by sympa.inria.fr (Postfix) with ESMTPS id 0F63D7F0BA for ; Thu, 9 Feb 2017 10:52:29 +0100 (CET) Authentication-Results: mail3-smtp-sop.national.inria.fr; spf=None smtp.pra=martindemello@gmail.com; spf=Pass smtp.mailfrom=martindemello@gmail.com; spf=None smtp.helo=postmaster@mail-qt0-f179.google.com Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of martindemello@gmail.com) identity=pra; client-ip=209.85.216.179; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="martindemello@gmail.com"; x-sender="martindemello@gmail.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail3-smtp-sop.national.inria.fr: domain of martindemello@gmail.com designates 209.85.216.179 as permitted sender) identity=mailfrom; client-ip=209.85.216.179; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="martindemello@gmail.com"; x-sender="martindemello@gmail.com"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of postmaster@mail-qt0-f179.google.com) identity=helo; client-ip=209.85.216.179; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="martindemello@gmail.com"; x-sender="postmaster@mail-qt0-f179.google.com"; x-conformance=sidf_compatible IronPort-PHdr: =?us-ascii?q?9a23=3AI7KiRx2mV/A2+auZsmDT+DRfVm0co7zxezQtwd8Z?= =?us-ascii?q?se0SI/ad9pjvdHbS+e9qxAeQG96Kt7QU16GO7+jJYi8p2d65qncMcZhBBVcuqP?= =?us-ascii?q?49uEgeOvODElDxN/XwbiY3T4xoXV5h+GynYwAOQJ6tL1LdrWev4jEMBx7xKRR6?= =?us-ascii?q?JvjvGo7Vks+7y/2+94fdbghMizexe7B/IRq5oQnNucQdnJdvJLs2xhbVuHVDZv?= =?us-ascii?q?5YxXlvJVKdnhb84tm/8Zt++ClOuPwv6tBNX7zic6s3UbJXAjImM3so5MLwrhnM?= =?us-ascii?q?URGP5noHXWoIlBdDHhXI4wv7Xpf1tSv6q/Z91SyHNsD4Ubw4RTKv5LptRRT1ii?= =?us-ascii?q?kIKiQ5/XnXhMJ+j6xVvQyvqABkzoHOfI2YLuBzcr/Bcd4YQ2dKQ8ZfVzZGAoO5?= =?us-ascii?q?d4YBCPAOPfxEr4n8oVsFsBWwCherCuzxzj9Ignj21rA93uQkCw7GxhAgH9MIsH?= =?us-ascii?q?vJstr1MbkdUeSxzKnP1jjDYPZW1i386IjMaBwuvfaMXbdpfMfX1EIhFBvFg02O?= =?us-ascii?q?pYD5Oz6ZzOcAvmiB4+Z+SO6iinQrpxxzrzWrwMonl5PHiZgPyl/e8CV02IY1Ks?= =?us-ascii?q?O8SE58edOkFYFftyCeN4dvW8MiX31ktD80yrEbu5O2eDIGyJsgxx7YZPyHd5aH?= =?us-ascii?q?7gj/W+aWJDd0nHNleLShiBau6UWs1PHwW82u3FtJridJiMfAum0M2hDJ98SKSP?= =?us-ascii?q?9w8l+k2TmV1gDT7u9EIVozlareM5Mhx6Q/loAPsUTCGC/5hVv5jKqIeUUg/uio?= =?us-ascii?q?7P/qYrrjppCGNo90jhvyPbgpmsy6Geg4KBQBX3CH+eSg073u5VH2T69Pjv0yi6?= =?us-ascii?q?XZtJHaJd8HpqOiGA9U0oMj6w6lADu80dQYm2MHLFNfdx6dgYjpIQKGHPetR/y2?= =?us-ascii?q?hlDplDZw29jHOKfgC9PDNDKLxLzoeLI4709H1CIyy8pe7tRaEOdSDuj0XxrUvc?= =?us-ascii?q?bEDxlxHwGRzuLjD50p04oERWOJDqKcPafWtneH4+suJ6+HY4pD62W1EOQs+/O7?= =?us-ascii?q?1SxxolQaZ6T8hZY=3D?= X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: =?us-ascii?q?A0DkDAAxO5xYf7PYVdFdHRgHDBgHhQQHg?= =?us-ascii?q?1KlDYw7gguJFwdGEQEBAQEBAQEBAQEBEgEBCQsLChsmC0IBAQEBAQEGAgKBYRm?= =?us-ascii?q?CRwQZARseAxIJBzcCJAERAQUBFgyJbgEDFZ98g0A/jAKBaxgFARyDCQWDXAoZJ?= =?us-ascii?q?w1Vg18CBhKGOoxJgl8FkEGLL5ISkQWRTBQegRU5A4EZT2iGTB81gjEPFYYpAQE?= =?us-ascii?q?B?= X-IPAS-Result: =?us-ascii?q?A0DkDAAxO5xYf7PYVdFdHRgHDBgHhQQHg1KlDYw7gguJFwd?= =?us-ascii?q?GEQEBAQEBAQEBAQEBEgEBCQsLChsmC0IBAQEBAQEGAgKBYRmCRwQZARseAxIJB?= =?us-ascii?q?zcCJAERAQUBFgyJbgEDFZ98g0A/jAKBaxgFARyDCQWDXAoZJw1Vg18CBhKGOox?= =?us-ascii?q?Jgl8FkEGLL5ISkQWRTBQegRU5A4EZT2iGTB81gjEPFYYpAQEB?= X-IronPort-AV: E=Sophos;i="5.35,349,1484002800"; d="scan'208,217";a="212605572" Received: from mail-qt0-f179.google.com ([209.85.216.179]) by mail3-smtp-sop.national.inria.fr with ESMTP/TLS/AES128-GCM-SHA256; 09 Feb 2017 10:52:28 +0100 Received: by mail-qt0-f179.google.com with SMTP id k15so191683134qtg.3 for ; Thu, 09 Feb 2017 01:52:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=iN2NihYf0Q4vS0LtZyb+6SMfN185F+3IA2nX3iMq+Oc=; b=oTWftYlWFfKLE2dooyF7hlCbfxxAmLPMcnsCOt7glErJBwx6Auc/VdJbeWtPz3ipXC GADNRxDSACySxGGMtZyafMWAzGpgxddadWqpF6w0SjUevc1gd9KmUBBrKIW1FxiujTTd Cwi0PVKxNsKamQkvSGZ6G2w71i+2M0rcapQehsmbyECFwP3HB6F/9K9mSpUuw2AzONkL D+5HxtMKdyyII8qZrE4w6rqZUjUjcnwaCGKjn5y3G3fPbYTxaeuIyQMqNhxOh/u+8LCQ HQKoptmEtsY/jSCFKIjq05HWTdzj+4eTSqzwU+xHTAJxNJ4I5IPSVtczZzzTaFQUWq3/ pP+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=iN2NihYf0Q4vS0LtZyb+6SMfN185F+3IA2nX3iMq+Oc=; b=uZ3Q+QJrbXl33acxoRcF4C5b5u7393lhdWVt/Ba4BdBYOVoivVJM93QriKXc2j84hG rW1IFtHiUikFLJw/CZkN5dGapBEXcr/LVLZ4esVmFdc28CS9w1eCI8DrB8dGpw/sSYvo 3b/BPOx6kPvVNCmUa5KF4K9lf6yX24g1yflPSwUYWghdu8CyiOCcOrEnneUVAX2BbP72 DL6F84zN56E9gjdHS6r8SSfHUUsYReR44t5UfXSexEk0dj5VRTnp6nUU0tEezx3K95fP X0xPyHuFREmghVwWfmEaIr32+PTQuqDqlDiGIAJV1YnsV00WqBm6W5eLK2JY7MDcpP9D SUcw== X-Gm-Message-State: AMke39lZwn4E6l5d3ZBNPmT4BtF/9rmrZTl6O5VQYjxTHMwl5Lv6lSSOhymGLMRUW1QYOmQVjpo/wIdpN4cu5w== X-Received: by 10.200.41.91 with SMTP id z27mr2054085qtz.116.1486633946660; Thu, 09 Feb 2017 01:52:26 -0800 (PST) MIME-Version: 1.0 Received: by 10.237.62.246 with HTTP; Thu, 9 Feb 2017 01:52:26 -0800 (PST) From: Martin DeMello Date: Thu, 9 Feb 2017 01:52:26 -0800 Message-ID: To: "caml-list@inria.fr" Content-Type: multipart/alternative; boundary=001a1146fa384d4867054815f045 Subject: [Caml-list] intersections of polymorphic variants --001a1146fa384d4867054815f045 Content-Type: text/plain; charset=UTF-8 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 --001a1146fa384d4867054815f045 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
In the fo= llowing code:

type color =3D [`Red | `B= lue | `Green | `Black | `White]

let col= or_index c =3D match c with
=C2=A0 | `Red -> 1=C2=A0
=C2=A0 | `Blue -> 2=C2=A0
=C2=A0 | `Green -> 3=C2=A0
=C2=A0 | `Black -> 4=C2=A0
<= font face=3D"monospace, monospace">=C2=A0 | `White -> 5=C2=A0

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

type state =3D Color of int | Missing<= /font>

= let state_of_value v =3D match v with
=C2=A0 | `Red -> Col= or (color_index `Red)
= =C2=A0 | `Blue -> Color (color_index `Blue)
=C2=A0 | `Green -> Color (color_index `Green)<= /font>
=C2=A0 | `Missing ->= ; Missing

is there any way to write the las= t function as

let state_of_value v =3D match v with
=C2=A0 | `Red=C2=A0 | `Blue=C2=A0 | `Green -> ?????
=C2=A0 | `Missing -> Missing

martin
--001a1146fa384d4867054815f045--