From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by yquem.inria.fr (Postfix) with ESMTP id 8AA41BC57 for ; Fri, 3 Sep 2010 23:17:44 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AuoGAG8CgUxQDPJxZmdsb2JhbACDGJBTjSYVDQsICBIDH64lkgGBIoMmcwQ X-IronPort-AV: E=Sophos;i="4.56,315,1280700000"; d="scan'208";a="68840475" Received: from smtp2e.orange.fr ([80.12.242.113]) by mail4-smtp-sop.national.inria.fr with ESMTP; 03 Sep 2010 23:17:44 +0200 Received: from me-wanadoo.net (localhost [127.0.0.1]) by mwinf2e22.orange.fr (SMTP Server) with ESMTP id E15D68000481; Fri, 3 Sep 2010 23:17:43 +0200 (CEST) Received: from me-wanadoo.net (localhost [127.0.0.1]) by mwinf2e22.orange.fr (SMTP Server) with ESMTP id D083980003CE; Fri, 3 Sep 2010 23:17:43 +0200 (CEST) Received: from haddock.home (ADijon-153-1-75-151.w81-49.abo.wanadoo.fr [81.49.178.151]) by mwinf2e22.orange.fr (SMTP Server) with ESMTP id 9B0BD8000481; Fri, 3 Sep 2010 23:17:41 +0200 (CEST) X-ME-UUID: 20100903211741635.9B0BD8000481@mwinf2e22.orange.fr X-ME-User-Auth: maxence.guesdon Date: Fri, 3 Sep 2010 23:13:18 +0200 From: Maxence Guesdon To: caml-list@yquem.inria.fr Subject: Re: [Caml-list] Create a constraint between variant type and data list Message-ID: <20100903231318.7b92af7c@haddock.home> In-Reply-To: References: X-Mailer: Claws Mail 3.7.6 (GTK+ 2.20.1; i486-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Spam: no; 0.00; maxence:01 guesdon:01 maxence:01 guesdon:01 le-gall:01 lgpl:01 lgpl:01 variants:01 variants:01 compiler:01 compiler:01 polymorphic:01 gpl:01 gpl:01 caml-list:01 Le Fri, 3 Sep 2010 17:16:48 +0000 (UTC), Sylvain Le Gall a =C3=A9crit : > Hello all, >=20 > I would like to somehow enforce that a variant type is associated with > an entry in a data list.=20 >=20 > For example,=20 >=20 > I would like to define: >=20 > type license =3D GPL | LGPL=20 >=20 > and=20 >=20 > let data =3D [ GPL, "GNU Public license";=20 > LGPL, "GNU Lesser General Public license" ] >=20 >=20 > I would like to enforce that all variants of license are in the > association list. >=20 > I have tried to use polymorphic variants, but don't see how to enforce > this constraint. >=20 > The point, is that if I add a new variant to license (e.g. BSD3), the > compiler output an error because this new variant is not in data list. >=20 > Any ideas ? If you need to use another type expression rather than > variant, please do so, as long as I am able to link the license type > and data list. A solution is to add your new license to your list of associations, then the compiler will complain about the unknown variant :) Regards, --=20 Maxence Guesdon