Version française
Home     About     Download     Resources     Contact us    
Browse thread
Recursive module and class
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Jun Furuse <jun.furuse@g...>
Subject: Recursive module and class
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