From: "Milan Stanojević" <milanst@gmail.com>
To: Markus Mottl <markus.mottl@gmail.com>
Cc: Caml List <caml-list@inria.fr>
Subject: Re: [Caml-list] strange error with packed modules and module type of
Date: Thu, 7 Jun 2012 15:53:26 -0400 [thread overview]
Message-ID: <CAKR7PS-b2tidq=Ho7BzXukVr7KO4J_x9T3Fx5VMV5WEmouT=Bw@mail.gmail.com> (raw)
In-Reply-To: <CAP_800qvf6r3XcSvEjYwnA=zreW2W1WeyYLRUKuGmp8ehfZOZA@mail.gmail.com>
If I just do
ocamlopt.opt -for-pack G -c foo.mli foo.ml
ocamlopt.opt -pack -o g.cmx foo.cmx
that is, forget all the fancyness with std and specifying interface
for G, the resulting G module has the type
sig module Foo : sig type t = G.Foo.t val x : t end end
So somehow the resulting interface of G is defined in terms of itself?!
Should I just file this problem on ocaml mantis?
p.s the only way I was able to get interface for G is to make a helper
program that uses G with a wrong signature and get the compiler to
give me the type in the error message. Is there a better way?
main:ml
module F : sig type t end = G
let () = ()
$ ocamlopt.opt g.cmx main.ml
File "main.ml", line 1, characters 28-29:
Error: Signature mismatch:
Modules do not match:
sig module Foo : sig type t = G.Foo.t val x : t end end
is not included in
sig type t end
The field `t' is required but not provided
On Tue, May 29, 2012 at 10:30 PM, Markus Mottl <markus.mottl@gmail.com> wrote:
> On Tue, May 29, 2012 at 8:25 PM, Milan Stanojević <milanst@gmail.com> wrote:
>> g.mli:
>> module Std : sig include module type of Std end
>
> Btw., this is equivalent and slightly shorter:
>
> module Std : module type of Std
>
>> and compile similarly like before
>> ocamlopt.opt -for-pack G -c foo.mli foo.ml
>> ocamlopt.opt -for-pack G -c foo.cmx std.ml
>> ocamlopt.opt -c g.mli
>> ocamlopt.opt -pack -o g.cmx foo.cmx std.cmx
>>
>> But now I get this helpful error message
> [snip]
>> Does anyone know what is going on here?
>
> This seemingly identical construction compiles:
>
> g.mli:
> module Std : sig module Foo : module type of Foo end
>
> I guess this also points to what is going wrong. If I understand this
> correctly, the workaround basically says: "Std contains a submodule
> Foo which just happens to have the same signature as the module
> implemented by foo.ml". But the broken version says: "Std contains a
> submodule Foo which is equivalent to the module implemented by
> foo.ml". This equivalence is somehow lost with packing, hence the
> unhelpful error message. Not sure, but I guess this can be fixed in
> the compiler?
>
> Regards,
> Markus
>
> --
> Markus Mottl http://www.ocaml.info markus.mottl@gmail.com
next prev parent reply other threads:[~2012-06-07 19:54 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-05-30 0:25 Milan Stanojević
2012-05-30 2:30 ` Markus Mottl
2012-06-07 19:53 ` Milan Stanojević [this message]
2012-06-07 23:37 ` Jacques Garrigue
2012-06-08 20:36 ` Milan Stanojević
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='CAKR7PS-b2tidq=Ho7BzXukVr7KO4J_x9T3Fx5VMV5WEmouT=Bw@mail.gmail.com' \
--to=milanst@gmail.com \
--cc=caml-list@inria.fr \
--cc=markus.mottl@gmail.com \
/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