Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] signature mismatch
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Andreas Rossberg <rossberg@p...>
Subject: Re: [Caml-list] signature mismatch
Pietro Abate wrote:
> 
> how can I force BB.t to be the same as AA.t ?

module BB : A2 with type t = A1.t = struct
     type t = A1.t
     let toast f1 f2 = false
end

 > why it's not enforced by the functor declaration (with type...) ?

Well, it is, but probably in a sense different from what you think. 
That's why the compiler complains, because the constraint is not 
satisfied for the arguments you pass to the functor.

When you write

> module AA : A1 = ...

You declare module AA and introduce an abstract type t. That means that 
AA.t is a fresh type, distinct from any other type in your program. 
Likewise with

> module BB : A2 = ...

In particular, both types are distinct from each other (and int!). 
Consequently,

> module C = Make (AA) (BB)

is not well typed, because the constraint you state on Make's arguments 
requires AA.t and BB.t to be equivalent, which they aren't.

The solution, as sketched above, is to avoid type abstraction for at 
least one of the modules.

Hope this helps,

| Andreas

-- 
Andreas Rossberg, rossberg@ps.uni-sb.de

"Computer games don't affect kids; I mean if Pac Man affected us
  as kids, we would all be running around in darkened rooms, munching
  magic pills, and listening to repetitive electronic music."
  - Kristian Wilson, Nintendo Inc.

-------------------
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