From: Ashish Agarwal <agarwal1975@gmail.com>
To: Caml List <caml-list@inria.fr>
Subject: [Caml-list] types not equal when I expect them to be
Date: Thu, 1 Mar 2012 11:38:50 -0500 [thread overview]
Message-ID: <CAMu2m2LSymhSZ+u78Eiwb-LA2QhiMjHiwb45gOd2TfpS3Y9wHA@mail.gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 1112 bytes --]
The following code fails to compile:
----- a.ml ----
module Foo = struct
module St = struct type t = string let compare = compare end
module Map (* : Map.S with type key = St.t *)
= Map.Make(St)
(* module Map = Map.Make(struct type t = string let compare = compare
end) *)
end
module Bar = struct
type t = int Foo.Map.t
end
module Pack = struct
module Foo = Foo
module Bar = Bar
end
open Pack
let x : Bar.t = Foo.Map.empty
----
$ ocamlc -c foo.ml
File "foo.ml", line 20, characters 16-29: (* refers to Foo.Map.empty on
last line *)
Error: This expression has type
'a Pack.Foo.Map.t = 'a Map.Make(Pack.Foo.St).t
but an expression was expected of type
Pack.Bar.t = int Map.Make(Foo.St).t
So Pack.Foo and Foo are not compatible. By trial and error, I found two
ways to resolve the problem:
1) Provide an explicit signature for Foo.Map (uncomment the provided
signature), or
2) Inline the structure passed to Map.Make (comment out first definition of
Foo.Map and uncomment the second one)
But I don't understand why. Can anyone explain the main points. Thank you.
[-- Attachment #2: Type: text/html, Size: 1737 bytes --]
next reply other threads:[~2012-03-01 16:39 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-01 16:38 Ashish Agarwal [this message]
2012-03-01 22:18 ` Gabriel Scherer
[not found] <fa.O3xm0idbEURic/azoi8VH23mQEw@ifi.uio.no>
2012-03-07 8:02 ` Radu Grigore
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=CAMu2m2LSymhSZ+u78Eiwb-LA2QhiMjHiwb45gOd2TfpS3Y9wHA@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).