Browse thread
a module with multiple signatures
[
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: | Keiko Nakata <keiko@k...> |
| Subject: | a module with multiple signatures |
Hello,
I tried to give a module different signatures through an use of functors.
Then I faced a situation for which I do not understand the reason.
This is the simplified version of my situation.
module M = struct type s = S type t = T1 | T2 of s end
module F1 = functor (X : sig type t end) -> struct type t = X.t end
module F2 = functor (X : sig type s type t end) ->
struct type s = X.s type t = X.t end
module M1 = F1(M)
module M2 = F2(M)
let f x = match x with M1.T1 -> 1 | M1.T2 x -> 2;;
(* This is not type checked *)
(* I got the error "Unbound constructor M1.T1" *)
(* This is type checked *)
let g (x : M1.t) = match x with M.T1 -> 1 | M.T2 x -> 2;;
Why M1.T1 should not be bound?
Anyway,
there may be a nicer way to give a module multiple signatures
while avoiding duplicate type declarations as possible?
(In the above setting, I want to make the type s in M abstract in some
context, but transparent in another context.)
Regards,
NAKATA Keiko