[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Christian Sternagel <christian.sternagel@u...> |
| Subject: | Problem with Functors and Module Types |
Hello,
once again I have some problems using functors with module types. I
produced following (almost?) minimal example:
module type MT_M = sig
type s
type t = A of s | B of t list
val f : t -> t
end
module type MT_N = sig
module M : MT_M
val f : 'a -> M.t
end
module type MT_A = sig
type t
end
module MakeM (A : MT_A) : MT_M with type s = A.t = struct
type s = A.t
type t = A of s | B of t list
let f x = x
end
module MakeN (A : MT_A) (* : MT_N *) = struct
module M = MakeM (A)
let f _ = M.B []
end
module A = struct
type t = int
end
module M = MakeM (A)
module N = MakeN (A)
let _ = (M.f (N.f 1))
This file compiles, but when I comment-in the module type restriction
for `MakeN' the error
This expression has type N.M.t = MakeN(A).M.t but is here used with type
M.t = MakeM(A).t
occurs. I understand that in the current setting the two types are not
equal for the compiler. However, my question is: Is there a way to tell
the compiler that the two types should be equal?
cheers
christian