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 mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by yquem.inria.fr (Postfix) with ESMTP id 82493BC6C for ; Wed, 6 Feb 2008 13:16:30 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgAAAIM0qUfAXQInh2dsb2JhbACQMgEBAQgKKZY4hlc X-IronPort-AV: E=Sophos;i="4.25,312,1199660400"; d="scan'208";a="22290360" Received: from concorde.inria.fr ([192.93.2.39]) by mail4-smtp-sop.national.inria.fr with ESMTP; 06 Feb 2008 13:16:12 +0100 Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by concorde.inria.fr (8.13.6/8.13.6) with ESMTP id m16CGBT9019547 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=OK) for ; Wed, 6 Feb 2008 13:16:12 +0100 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgAAABg0qUdA6bjskGdsb2JhbACQMgEBAQEHBAQJChEHljeGVw X-IronPort-AV: E=Sophos;i="4.25,312,1199660400"; d="scan'208";a="6990564" Received: from wr-out-0506.google.com ([64.233.184.236]) by mail2-smtp-roc.national.inria.fr with ESMTP; 06 Feb 2008 13:16:11 +0100 Received: by wr-out-0506.google.com with SMTP id c57so2853351wra.9 for ; Wed, 06 Feb 2008 04:16:10 -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:mime-version:content-type:content-transfer-encoding:content-disposition; bh=r709neiB2GTqJIw5LZOoc5QQ/h1eRyBViG56zd92faI=; b=QxX61FFnh/eo4/AscJddZfX2oEWiuJQIuQ9tg0y4dvubDC7V6M0mUoy0Ez43DGh/aLaALx0jUkWTeFAod72g3IgmQFkrHGRNropJJvTkNnm6REKV1IlW+ty9gJJwFDEGBMIt7U4IWhMIaYzdcRgYQ8VFUHA6ElADYirWyO/sio0= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; b=GRRBzZq8msEQ1tN1aTVr2b4bvyhJ+I7v3V/o3ie21fpsMOa8m1CTAlVy6STOK3dYnvX/gdzujnHIH2X+xkoL5M/1hUZVLNyU2QYbLlPoyA7JnD0h/bkscRUL4WHfD1mbng9wq651O+FNs1JunVQ722s1jKQv8CvRMyud8wanf9I= Received: by 10.142.172.12 with SMTP id u12mr5143842wfe.195.1202300168523; Wed, 06 Feb 2008 04:16:08 -0800 (PST) Received: by 10.142.98.15 with HTTP; Wed, 6 Feb 2008 04:16:08 -0800 (PST) Message-ID: <9d3ec8300802060416t39660ca3r9fbcf0fd1a161d43@mail.gmail.com> Date: Wed, 6 Feb 2008 12:16:08 +0000 From: "Till Varoquaux" To: "caml-list List" Subject: Empty polymorphic variant type MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-Disposition: inline X-Miltered: at concorde with ID 47A9A50B.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; variants:01 polymorphic:01 polymorphic:01 encode:01 constraint:01 constraint:01 variant:02 variant:02 objects:02 bogus:05 types:05 types:05 illustrate:06 phantom:07 phantom:07 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 -- http://till-varoquaux.blogspot.com/