caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: "Daniel Bünzli" <daniel.buenzli@epfl.ch>
To: caml-list@inria.fr
Subject: Phantom types and polymorphic variants
Date: Thu, 27 Jan 2005 01:00:13 +0100	[thread overview]
Message-ID: <6AFC6161-6FF6-11D9-ABDA-000393DBC266@epfl.ch> (raw)

Hello,

Suppose I have the following (well-typed) definitions

> type tool = [`Spoon | `Fork]
>
> type 'a t = unit constraint 'a = [< tool]
>
> type 'a toolspec = unit constraint 'a = [< tool]
>
> let spoon : [< tool > `Spoon ] toolspec = ()
> let fork : [< tool > `Fork ] toolspec = ()
>
> let create : ([< tool ] as 'a) -> 'a t = fun t -> ()
> let create' : ([< tool ] as 'a) toolspec -> 'a t = fun t -> ()

I don't really understand why the type of the value returned by create 
and create' differ :

> # create `Spoon;;
> - : [< Test.tool > `Spoon ] Test.t = ()
> # create' spoon;;
> - : [< Test.tool ] Test.t = ()

I expected the second value to have the same type as the first.

Thanks for your explanations,

Daniel


             reply	other threads:[~2005-01-27  0:00 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-01-27  0:00 Daniel Bünzli [this message]
2005-01-27  0:59 ` [Caml-list] " Jacques Garrigue

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=6AFC6161-6FF6-11D9-ABDA-000393DBC266@epfl.ch \
    --to=daniel.buenzli@epfl.ch \
    --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).