caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Virgile Prevosto <virgile.prevosto@m4x.org>
To: OCAML <caml-list@inria.fr>
Subject: [Caml-list] typechecking in 4.05+beta2
Date: Wed, 22 Feb 2017 19:54:31 +0100	[thread overview]
Message-ID: <CA+yPOVj8UJKVpu5pxQ92741CX1Aa3fiLkqgz+jiJL1XOecFjRA@mail.gmail.com> (raw)

Dear list,

while playing with the new beta, I stumbled upon the following issue.
The program below is now rejected by the compiler, while this was not
the case with 4.04.

--- test.mli:
module M(E: sig type t end): sig
type t
val u: t -> t -> t
end

--- test.ml:
module M(E: sig type t end) = struct
type t = (E.t, unit) Hashtbl.t
let u = Hashtbl.fold (fun x () h -> Hashtbl.add h x (); h)
end

---
ocamlc test.mli
ocamlc test.ml
File "test.ml", line 1:
Error: The implementation test.ml does not match the interface test.cmi:
       ...
       At position module M(E) : <here>
       Modules do not match:
         sig
           type t = (E.t, unit) Hashtbl.t
           val u :
             ('_a, unit) Hashtbl.t ->
             ('_a, unit) Hashtbl.t -> ('_a, unit) Hashtbl.t
         end
       is not included in
         sig type t val u : t -> t -> t end
       At position module M(E) : <here>
       Values do not match:
         val u :
           ('_a, unit) Hashtbl.t ->
           ('_a, unit) Hashtbl.t -> ('_a, unit) Hashtbl.t
       is not included in
         val u : t -> t -> t
       File "test.ml", line 3, characters 4-5: Actual declaration

It is quite easy to fix, but I was wondering whether this restriction
in type unification when checking the conformance of .ml and .mli was
intended, and if yes, what is the reason behind it?
Note that this is of course a reduction of the initial code, and all
ingredients seems to be needed.

Best regards,
-- 
E tutto per oggi, a la prossima volta
Virgile

             reply	other threads:[~2017-02-22 18:54 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-22 18:54 Virgile Prevosto [this message]
2017-02-24  8:47 ` Virgile Prevosto
2017-02-24 16:14   ` Gabriel Scherer
2017-02-24 18:19     ` Virgile Prevosto

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=CA+yPOVj8UJKVpu5pxQ92741CX1Aa3fiLkqgz+jiJL1XOecFjRA@mail.gmail.com \
    --to=virgile.prevosto@m4x.org \
    --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).