caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Ashish Agarwal <agarwal1975@gmail.com>
To: Caml List <caml-list@inria.fr>
Subject: [Caml-list] ocaml 4.00.1 and 4.01.0 behave differently on module type constraint
Date: Tue, 28 Jan 2014 16:19:48 -0500	[thread overview]
Message-ID: <CAMu2m2LNRDsZEBB8Vu+YfTe--i3RmdmXMZiHEmihh5xEicuP5Q@mail.gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 1578 bytes --]

Is the following an expected change from OCaml 4.00.1 to 4.01.0?

Module Foo defines a private type and this module is included in Common.
The signature within Common is defined using `module type of` with a
constraint. The different behavior shown below occurs when the private type
is a record, but not if it is a base type like string or int. In that case,
the code compiles with both 4.00.1 and 4.01.0.

$ cat a.ml
module Foo : sig
  type t = private {a:int}
end = struct
  type t = {a:int}
end

module Common : sig
  module F : module type of Foo with type t = Foo.t
end = struct
  module F = Foo
end

$ ocaml -version
The OCaml toplevel, version 4.01.0

$ ocaml a.ml
(* no errors *)

Now, change version of OCaml being used.

$ ocaml -version
The OCaml toplevel, version 4.00.1

$ ocaml a.ml
File "a.ml", line 9, characters 6-33:
Error: Signature mismatch:
       Modules do not match:
         sig module F : sig type t = Foo.t = private { a : int; } end end
       is not included in
         sig module F : sig type t = Foo.t = { a : int; } end end
       In module F:
       Modules do not match:
         sig type t = Foo.t = private { a : int; } end
       is not included in
         sig type t = Foo.t = { a : int; } end
       In module F:
       Type declarations do not match:
         type t = Foo.t = private { a : int; }
       is not included in
         type t = Foo.t = { a : int; }
       File "a.ml", line 8, characters 37-51: Expected declaration
       File "a.ml", line 2, characters 7-26: Actual declaration
       A private type would be revealed.

[-- Attachment #2: Type: text/html, Size: 2347 bytes --]

             reply	other threads:[~2014-01-28 21:20 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-28 21:19 Ashish Agarwal [this message]
2014-01-28 21:43 ` Gabriel Scherer
2014-01-28 23:16   ` Ashish Agarwal

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=CAMu2m2LNRDsZEBB8Vu+YfTe--i3RmdmXMZiHEmihh5xEicuP5Q@mail.gmail.com \
    --to=agarwal1975@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).