caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: "Till Varoquaux" <till.varoquaux@gmail.com>
To: "caml-list List" <caml-list@inria.fr>
Subject: Empty polymorphic variant type
Date: Wed, 6 Feb 2008 12:16:08 +0000	[thread overview]
Message-ID: <9d3ec8300802060416t39660ca3r9fbcf0fd1a161d43@mail.gmail.com> (raw)

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/


             reply	other threads:[~2008-02-06 12:16 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-02-06 12:16 Till Varoquaux [this message]
2008-02-06 12:24 ` Till Varoquaux
2008-02-06 12:33   ` [Caml-list] " Bünzli Daniel
2008-02-06 13:13     ` Till Varoquaux
2008-02-07 15:18   ` Christophe TROESTLER

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=9d3ec8300802060416t39660ca3r9fbcf0fd1a161d43@mail.gmail.com \
    --to=till.varoquaux@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;
as well as URLs for NNTP newsgroup(s).