* [Caml-list] signature mismatch
@ 2003-06-17 13:27 Pietro Abate
2003-06-17 13:44 ` Damien Pous
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Pietro Abate @ 2003-06-17 13:27 UTC (permalink / raw)
To: caml-list
Hi all,
I get this error trying to compile the file below:
File "pp.ml", line 28, characters 22-24:
Signature mismatch:
Modules do not match:
sig type t = BB.t val toast : t -> t -> bool end
is not included in
sig type t = AA.t val toast : t -> t -> bool end
Type declarations do not match:
type t = BB.t
is not included in
type t = AA.t
how can I force BB.t to be the same as AA.t ?
why it's not enforced by the functor declaration (with type...) ?
tnx,
p
file :
-----------------
module type A1 = sig
type t
val test : t -> t -> bool
end
module type A2 = sig
type t
val toast : t -> t -> bool
end
module Make (A : A1 ) (B : A2 with type t = A.t) = struct
let fifi a b c =
if c > 1 then A.test a b
else B.toast b a
end
module AA : A1 = struct
type t = int
let test f1 f2 = true
end
module BB : A2 = struct
type t = int
let toast f1 f2 = false
end
module C = Make (AA) (BB)
---------------------
--
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] 6+ messages in thread
* Re: [Caml-list] signature mismatch
2003-06-17 13:27 [Caml-list] signature mismatch Pietro Abate
@ 2003-06-17 13:44 ` Damien Pous
2003-06-17 13:46 ` Jean-Christophe Filliatre
2003-06-17 14:01 ` Andreas Rossberg
2 siblings, 0 replies; 6+ messages in thread
From: Damien Pous @ 2003-06-17 13:44 UTC (permalink / raw)
Cc: caml-list
AA.t and BB.t are two distinct abstract types, so they can't be unified,
you should export the type definitions in AA and BB :
module AA : A1 with type t = int = struct
type t = int
let test f1 f2 = true
end
module BB : A2 with type t = int = struct
type t = int
let toast f1 f2 = false
end
module C = Make (AA) (BB)
damien
-------------------
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] 6+ messages in thread
* Re: [Caml-list] signature mismatch
2003-06-17 13:27 [Caml-list] signature mismatch Pietro Abate
2003-06-17 13:44 ` Damien Pous
@ 2003-06-17 13:46 ` Jean-Christophe Filliatre
2003-06-17 14:01 ` Andreas Rossberg
2 siblings, 0 replies; 6+ messages in thread
From: Jean-Christophe Filliatre @ 2003-06-17 13:46 UTC (permalink / raw)
To: Pietro Abate; +Cc: caml-list
Pietro Abate writes:
> Hi all,
> I get this error trying to compile the file below:
>
> File "pp.ml", line 28, characters 22-24:
> Signature mismatch:
> Modules do not match:
> sig type t = BB.t val toast : t -> t -> bool end
> is not included in
> sig type t = AA.t val toast : t -> t -> bool end
> Type declarations do not match:
> type t = BB.t
> is not included in
> type t = AA.t
>
> how can I force BB.t to be the same as AA.t ?
> why it's not enforced by the functor declaration (with type...) ?
Types AA.t and BB.t are abstract, due to the declarations "module AA :
A1" and "module BB : A2" and to the fact that "t" is abstract in both
interfaces A1 and A2. You should write instead
module AA : A1 with type t = int = ...
module BB : A2 with type t = int = ...
module C = Make (AA) (BB)
(Another possibility is to declare "type t = int" in both signatures
A1 and A2 but it is probably not what you want to do.)
--
Jean-Christophe Filliâtre (http://www.lri.fr/~filliatr)
> -----------------
> module type A1 = sig
> type t
> val test : t -> t -> bool
> end
>
> module type A2 = sig
> type t
> val toast : t -> t -> bool
> end
>
> module Make (A : A1 ) (B : A2 with type t = A.t) = struct
> let fifi a b c =
> if c > 1 then A.test a b
> else B.toast b a
> end
>
> module AA : A1 = struct
> type t = int
> let test f1 f2 = true
> end
>
> module BB : A2 = struct
> type t = int
> let toast f1 f2 = false
> end
>
> module C = Make (AA) (BB)
>
> ---------------------
>
> --
> 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
-------------------
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] 6+ messages in thread
* Re: [Caml-list] signature mismatch
2003-06-17 13:27 [Caml-list] signature mismatch Pietro Abate
2003-06-17 13:44 ` Damien Pous
2003-06-17 13:46 ` Jean-Christophe Filliatre
@ 2003-06-17 14:01 ` Andreas Rossberg
2003-06-18 8:30 ` Julien Signoles
2 siblings, 1 reply; 6+ messages in thread
From: Andreas Rossberg @ 2003-06-17 14:01 UTC (permalink / raw)
To: caml-list
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
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Caml-list] signature mismatch
2003-06-17 14:01 ` Andreas Rossberg
@ 2003-06-18 8:30 ` Julien Signoles
2003-06-18 8:56 ` Andreas Rossberg
0 siblings, 1 reply; 6+ messages in thread
From: Julien Signoles @ 2003-06-18 8:30 UTC (permalink / raw)
To: caml-list
On Tue, 17 Jun 2003, Andreas Rossberg wrote:
> 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
It does not work because A1 is used as a structure identifier.
It's ok if you replace A1 by AA.
Julien
--
mailto : Julien.Signoles@lri.fr ; http : www.lri.fr/~signoles
"In theory, practice and theory are the same,
but in practice they are different" (Larry McVoy)
-------------------
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] 6+ messages in thread
* Re: [Caml-list] signature mismatch
2003-06-18 8:30 ` Julien Signoles
@ 2003-06-18 8:56 ` Andreas Rossberg
0 siblings, 0 replies; 6+ messages in thread
From: Andreas Rossberg @ 2003-06-18 8:56 UTC (permalink / raw)
To: caml-list
Julien Signoles wrote:
> On Tue, 17 Jun 2003, Andreas Rossberg wrote:
>
>>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
>
> It does not work because A1 is used as a structure identifier.
> It's ok if you replace A1 by AA.
Of course, you are completely right. Should have reread my reply before
posting...
--
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
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2003-06-18 8:59 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-06-17 13:27 [Caml-list] signature mismatch Pietro Abate
2003-06-17 13:44 ` Damien Pous
2003-06-17 13:46 ` Jean-Christophe Filliatre
2003-06-17 14:01 ` Andreas Rossberg
2003-06-18 8:30 ` Julien Signoles
2003-06-18 8:56 ` Andreas Rossberg
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox