Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
[Caml-list] type and modules... (sig mismatch again)
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2003-06-18 (10:41)
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 ?


module type A = sig
    type t1
    type t2
    val tutu : t1 -> t2

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)

Civilization advances by extending the number
of important operations which we can perform 
without thinking. (Alfred North Whitehead)

To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: