Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
* [Caml-list] type and modules... (sig mismatch again)
@ 2003-06-18 10:41 Pietro Abate
  2003-06-18 11:07 ` Damien Pous
  2003-06-18 11:09 ` Andreas Rossberg
  0 siblings, 2 replies; 3+ messages in thread
From: Pietro Abate @ 2003-06-18 10:41 UTC (permalink / raw)
  To: caml-list

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


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2003-06-18 11:14 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-06-18 10:41 [Caml-list] type and modules... (sig mismatch again) Pietro Abate
2003-06-18 11:07 ` Damien Pous
2003-06-18 11:09 ` Andreas Rossberg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox