caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] a question about Ocaml semantics
@ 2017-05-26  8:08 Matej Kosik
  2017-05-26  8:38 ` Philippe Veber
  2017-05-26  9:09 ` Jeremy Yallop
  0 siblings, 2 replies; 5+ messages in thread
From: Matej Kosik @ 2017-05-26  8:08 UTC (permalink / raw)
  To: caml-list

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?

^ permalink raw reply	[flat|nested] 5+ messages in thread
* [Caml-list] a question about Ocaml semantics
@ 2017-04-26 14:26 Matej Kosik
  2017-04-26 20:09 ` Jeremy Yallop
  0 siblings, 1 reply; 5+ messages in thread
From: Matej Kosik @ 2017-04-26 14:26 UTC (permalink / raw)
  To: caml-list

Dear all,

I am not sure I understand particular aspect of Ocaml semantics.

In the context of an *.ml file, can

	struct include A end

be in general (i.e. unconditionally always) be rewritten to

	A

?

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2017-05-26  9:09 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-26  8:08 [Caml-list] a question about Ocaml semantics Matej Kosik
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

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).