From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: * X-Spam-Status: No, score=1.1 required=5.0 tests=AWL,SPF_NEUTRAL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by yquem.inria.fr (Postfix) with ESMTP id ADDDABC6C for ; Wed, 6 Feb 2008 13:24:25 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgAAADg1qUfAXQImh2dsb2JhbACQMgEBAQgKKZY5hlc X-IronPort-AV: E=Sophos;i="4.25,312,1199660400"; d="scan'208";a="6991092" Received: from discorde.inria.fr ([192.93.2.38]) by mail2-smtp-roc.national.inria.fr with ESMTP; 06 Feb 2008 13:24:25 +0100 Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id m16COFpx002194 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=OK) for ; Wed, 6 Feb 2008 13:24:25 +0100 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgAAAK81qUdA6bjrkGdsb2JhbACQMgEBAQEHBAQJChEHljaGVg X-IronPort-AV: E=Sophos;i="4.25,312,1199660400"; d="scan'208";a="22290896" Received: from wr-out-0506.google.com ([64.233.184.235]) by mail4-smtp-sop.national.inria.fr with ESMTP; 06 Feb 2008 13:24:24 +0100 Received: by wr-out-0506.google.com with SMTP id c57so2865420wra.9 for ; Wed, 06 Feb 2008 04:24:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; bh=u3DbLfz2dwYC04nD6kXLH5yIle9R3DU6Xkc/YuyTAHc=; b=ehZOeAvPGrwbGgY9vCVEm63/6kKoZBlvODs6rpAQrv1Rt6zAmqTYbf84IWElxzSQss1r+6xs27H5cpjI320WHhWgpzk072uRz8jroG+c4P283yE+f5aw8RZG5HUWH1Nx7+BI0WqPOjSjy0BYSMCrWc8P0aRn+F3HYZfjWdvN1wE= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=VC+c48GKA8frcoCKbI0NMOMnuxYgDRedFTWyLOSMJREtZsSYPEnctH9uKf5ggp9dtriw2pvzqyo9Q+kBZRg1wZD0pFhUISSsAkrCsUNyZuKr9Z2eANNvIi5DoCoc+qYkfbbL84ZY/gUfIZ9UMGZR84hlPnpC/0dSb9r4ueK/Pho= Received: by 10.142.101.17 with SMTP id y17mr5171356wfb.54.1202300661020; Wed, 06 Feb 2008 04:24:21 -0800 (PST) Received: by 10.142.98.15 with HTTP; Wed, 6 Feb 2008 04:24:21 -0800 (PST) Message-ID: <9d3ec8300802060424j6fbe3378m8ac51d14cc399d6b@mail.gmail.com> Date: Wed, 6 Feb 2008 12:24:21 +0000 From: "Till Varoquaux" To: "caml-list List" Subject: Re: Empty polymorphic variant type In-Reply-To: <9d3ec8300802060416t39660ca3r9fbcf0fd1a161d43@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <9d3ec8300802060416t39660ca3r9fbcf0fd1a161d43@mail.gmail.com> X-Miltered: at discorde with ID 47A9A6F0.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; variants:01 polymorphic:01 polymorphic:01 wrote:01 encode:01 constraint:01 constraint:01 variant:02 variant:02 objects:02 seems:03 bogus:05 types:05 types:05 illustrate:06 On Feb 6, 2008 12:16 PM, Till Varoquaux wrote: > Polymorohic variants are great to encode permissions as phantom types. > This usage is hindered by the apparent impossibility to declare the > empty polymorphic type. > > To illustrate this use case I'll take a bogus example: suppose one is > handling accounts, you might want to be able to add a permission on > private information (NIN, passwords etc..). So you could be handling > accounts where you'd have read permission, write permission both or > none. By using a polymorphic variant type: > > type 'a account constraint 'a = [< `Read | `Write ];; > > to could express as closed type 3 of 4 possible case, the one where > you have neither read nor write access cannot be expressed. > > One could use objects as phantom types: > > type 'a account constraint 'a = <..>;; > > but this solution is just not as elegant. Any other ideas? > > Till Small addendum: type 'a account constraint 'a = [< `Permission |`Read | `Write > `Permission ];; would work but it seems clunky and convoluted. Till > -- > http://till-varoquaux.blogspot.com/ > -- http://till-varoquaux.blogspot.com/