Browse thread
[Caml-list] type and modules... (sig mismatch again)
- Pietro Abate
[
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: | Pietro Abate <Pietro.Abate@a...> |
| Subject: | [Caml-list] type and modules... (sig mismatch again) |
Hi all,
my daily question :-))
I would like to write a module definition as below:
the problem is (of course) with the t1_t and t2_t type definition because the
use the same variant names. however in my understanding the signature + the "(A
with type t1 = t1_t and type t2 = t2_t)" bit in the functor declaration should
be enough to make clear to the compiler that tutu gets t1 and return t2. Hence
in the pattern matching the first A is of the type t1 and the B is of type t2.
how can I force this behavior without changing t1_t and t2_t ?
why the signature doesn't enforce the right type matching ?
regards,
pietro
module type A = sig
type t1
type t2
val tutu : t1 -> t2
end
type t1_t = A of int
type t2_t = A of int | B of int
module Make : (A with type t1 = t1_t and type t2 = t2_t) = struct
type t1 = t1_t
type t2 = t2_t
let tutu = function
|A(x) -> B(x)
end
--
Civilization advances by extending the number
of important operations which we can perform
without thinking. (Alfred North Whitehead)
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners