* [Caml-list] module name alias and typing
@ 2011-06-23 16:43 Radu Grigore
2011-06-23 16:45 ` [Caml-list] " Radu Grigore
0 siblings, 1 reply; 2+ messages in thread
From: Radu Grigore @ 2011-06-23 16:43 UTC (permalink / raw)
To: caml-list
The following code compiles as expected.
module Int = struct type t = int let compare = compare end
module Util = struct module IntSet = Set.Make (Int) end
let a = Util.IntSet.singleton 0
module U = Util
let b = U.IntSet.mem 0 a
However, if the definition of Int is moved inside Util then the
type-checker complaints that Util.IntSet.t and U.IntSet.t are
incompatible.
module Util =
module Int = struct type t = int let compare = compare end
struct module IntSet = Set.Make (Int)
end
let a = Util.IntSet.singleton 0
module U = Util
let b = U.IntSet.mem 0 a
I thought that "module X = Y" makes the names X and Y refer to the
same module. Is this correct?
Could someone explain what is going on in this example?
I tried with 3.11.2 and with 3.13.0+dev4 (2011-06-20).
^ permalink raw reply [flat|nested] 2+ messages in thread
* [Caml-list] Re: module name alias and typing
2011-06-23 16:43 [Caml-list] module name alias and typing Radu Grigore
@ 2011-06-23 16:45 ` Radu Grigore
0 siblings, 0 replies; 2+ messages in thread
From: Radu Grigore @ 2011-06-23 16:45 UTC (permalink / raw)
To: caml-list
Correction: misplaced "struct" keyword.
On Thu, Jun 23, 2011 at 5:43 PM, Radu Grigore <radugrigore@gmail.com> wrote:
> However, if the definition of Int is moved inside Util then the
> type-checker complaints that Util.IntSet.t and U.IntSet.t are
> incompatible.
module Util = struct
module Int = struct type t = int let compare = compare end
module IntSet = Set.Make (Int)
end
let a = Util.IntSet.singleton 0
module U = Util
let b = U.IntSet.mem 0 a
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2011-06-23 16:46 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-06-23 16:43 [Caml-list] module name alias and typing Radu Grigore
2011-06-23 16:45 ` [Caml-list] " Radu Grigore
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox