Hi,
I would like to understand type constraints in module type.
module type PROC = sig
type t
val empty : t
end
module type MODULE = sig
type t
module Proc : PROC
val empty : t
end
module type ICFG = sig
type t
module Module : MODULE
module Proc = Module.Proc
end
module Make (M : MODULE) : ICFG = struct
module Module = M
module Proc = M.Proc
type t = int
end
The above code does not compile and reports the following error:
Error: Signature mismatch:
...
In module Proc:
Modules do not match:
sig type t = M.Proc.t val empty : t val to_string : t -> string end
is not included in
(module Module.Proc)
- Is it a desired way to impose type constraint
module Proc = Module.Proc
? - What is the difference between the constraint and
module Proc : PROC with type t = Module.Proc.t
- Why does the above code fail to compile?