caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Jun Furuse <jun.furuse@gmail.com>
To: caml-list@inria.fr
Subject: Recursive module and class
Date: Wed, 09 Jul 2008 19:32:43 -0400	[thread overview]
Message-ID: <87abgqbplw.wl%jun.furuse@gmail.com> (raw)

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


             reply	other threads:[~2008-07-09 23:32 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-07-09 23:32 Jun Furuse [this message]
2008-07-12  7:34 ` [Caml-list] " Keiko Nakata
2008-07-10 13:43 Jun Furuse

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87abgqbplw.wl%jun.furuse@gmail.com \
    --to=jun.furuse@gmail.com \
    --cc=caml-list@inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).