caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Matej Kosik <5764c029b688c1c0d24a2e97cd764f@gmail.com>
To: caml-list@inria.fr
Subject: [Caml-list] a question about Ocaml semantics
Date: Fri, 26 May 2017 10:08:41 +0200	[thread overview]
Message-ID: <8de32ec3-f6ab-7c86-a270-7f7ccbe24d20@gmail.com> (raw)

Hi,

There's an Ocaml language feature I do not understand.

E.g. in this example:

  type 'a phantom = int
  type t = { enter : 'a. 'a phantom -> int }
  let f g = g.enter 2
  let _ = f { enter = fun x -> 1 + x } (* ok *)
  let _ = f { enter = (+) 1 }          (* fails to typecheck *)

I don't get why, if we have:

  type 'a phantom = int

i.e. "'a phantom" is defined as an alias of "int",
how is it possible that the following types:

  { enter : 'a. 'a phantom -> int }

is not equal to

  { enter : 'a. int -> int }

I've tried to find a corresponding section in the Reference Manual, but I failed.
Where is this explained?

             reply	other threads:[~2017-05-26  8:01 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-26  8:08 Matej Kosik [this message]
2017-05-26  8:38 ` Philippe Veber
2017-05-26  9:09 ` Jeremy Yallop
  -- strict thread matches above, loose matches on Subject: below --
2017-04-26 14:26 Matej Kosik
2017-04-26 20:09 ` Jeremy Yallop

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=8de32ec3-f6ab-7c86-a270-7f7ccbe24d20@gmail.com \
    --to=5764c029b688c1c0d24a2e97cd764f@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).