Dear all,
I have a likely newbie question on the module system, assume this program:
module U : sig type t end = struct type t = int end
module S : sig type t = C of U.t end = struct type t = C of U.t end
module T = struct
type s = S.t =
| C of U.t
end
module API : sig
module U : module type of U
module S : module type of S
module T : sig
type s = S.t
(* = C of U.t *)
end
end = struct
module U = U
module S = S
module T = T
end
Up to this point, everything goes OK, however, if I uncomment the C of U.t
bit, then OCaml complains with
This variant or record definition does not match that of type S.t
The types for field C are not equal.
That’s fairly strange as ocamlc -i
gives me the interface for the original version:
module U : sig type t end
module S : sig type t = C of U.t end
module T : sig type s = S.t = C of U.t end
module API :
sig
module U : sig type t end
module S : sig type t = C of U.t end
module T : sig type s = S.t end
end
which in principle compiles fine if I add the type constraint. Thanks!