* Recursive module and class
@ 2008-07-09 23:32 Jun Furuse
2008-07-12 7:34 ` [Caml-list] " Keiko Nakata
0 siblings, 1 reply; 3+ messages in thread
From: Jun Furuse @ 2008-07-09 23:32 UTC (permalink / raw)
To: caml-list
Hi,
Sorry if the following is already well known issue.
The following program trying to define a type and a class
mutually recursive is rejected by ocamlc
(3.11+dev12 Private_abbrevs+natdynlink (2008-02-29)):
module rec M : sig
type t = Foo of N.c
end = struct
type t = Foo of N.c
end and N : sig
class c : object method x : M.t end
end = struct
class c = object (self)
method x = M.Foo (self :> c)
end
end
The error message is puzzling:
Error: Signature mismatch:
Modules do not match:
sig class c : object method x : M.t end end
is not included in
sig class c : object method x : M.t end end
Type declarations do not match:
type c = N.c
is not included in
type c = < x : M.t >
These signatures are literaly same, but do not match.
The above code is compiled if I write
method x = M.Foo (self :> N.c)
to coerce the object to the outer class N.c instead of c.
Is it a bug of typing? Or it is ok but I was just confused by
the error message ?
--
Jun FURUSE
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Caml-list] Recursive module and class
2008-07-09 23:32 Recursive module and class Jun Furuse
@ 2008-07-12 7:34 ` Keiko Nakata
0 siblings, 0 replies; 3+ messages in thread
From: Keiko Nakata @ 2008-07-12 7:34 UTC (permalink / raw)
To: jun.furuse; +Cc: caml-list
Hello.
To the best of my knowledge, there is subtle interaction
between typing of recursive modules and unfolding of recursive structural types,
i.e, classes and polymorphic variants.
I remember Jacques has hit a similar problem:
http://caml.inria.fr/pub/ml-archives/caml-list/2008/02/de4c1ddaa8bf3c0ef9350d8fb4f1e8f7.en.html
My understanding is that with recursive modules you may define two types
that are equivalent but do not join together by simple unfolding
of abbreviations; this seems to confuse the type checker.
I believe this is a known bug of the current implementation
of the type checker.
With best regards,
Keiko
^ permalink raw reply [flat|nested] 3+ messages in thread
* Recursive module and class
@ 2008-07-10 13:43 Jun Furuse
0 siblings, 0 replies; 3+ messages in thread
From: Jun Furuse @ 2008-07-10 13:43 UTC (permalink / raw)
To: caml-list
[-- Attachment #1: Type: text/plain, Size: 1198 bytes --]
Hi,
Sorry if the following is already a known issue.
The following program trying to define a type and a class mutually recursive
is rejected by ocamlc (3.11+dev12 Private_abbrevs+natdynlink (2008-02-29)):
module rec M : sig
type t = Foo of N.c
end = struct
type t = Foo of N.c
end and N : sig
class c : object method x : M.t end
end = struct
class c = object (self)
method x = M.Foo (self :> c)
end
end
The error message is puzzling:
Error: Signature mismatch:
Modules do not match:
sig class c : object method x : M.t end end
is not included in
sig class c : object method x : M.t end end
Type declarations do not match:
type c = N.c
is not included in
type c = < x : M.t >
These signatures are literaly same, but do not match.
The above code is accepted by the compiler if I write
method x = M.Foo (self :> N.c)
to coerce the object to the outer class N.c instead of c.
Is it a bug of typing? Or is it ok but with a puzzling error message ?
--
Jun FURUSE
[-- Attachment #2: Type: text/html, Size: 2037 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2008-07-12 7:34 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-07-09 23:32 Recursive module and class Jun Furuse
2008-07-12 7:34 ` [Caml-list] " Keiko Nakata
2008-07-10 13:43 Jun Furuse
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox