caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Daniel Nuffer <nuffer@gmail.com>
To: caml-list@inria.fr
Subject: [Caml-list] Strange type error with recursive modules
Date: Thu, 13 Jun 2013 16:22:03 -0400	[thread overview]
Message-ID: <CAHZEYYOsJQFoWC8Je0k+xKHGxsfCAYe_v605unkop6_dAdi7HQ@mail.gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 603 bytes --]

Can anyone explain why this does not compile:

module rec A : sig
  type t
end = struct
  type z = { x : B.t }

  type t = z

  let foo t = B.foo t.x t (* Error: This expression has type t but an
expression was expected of type A.t *)
end

and B : sig
  type t
  val foo : B.t -> A.t -> unit
end = struct
  type t
  let foo _ _ = ()
end

Note that if there's no type aliasing in A, it will succeed:


module rec A : sig
  type t
end = struct
  type t = { x : B.t }

  let foo t = B.foo t.x t
end

and B : sig
  type t
  val foo : B.t -> A.t -> unit
end = struct
  type t
  let foo _ _ = ()
end

Thanks!

[-- Attachment #2: Type: text/html, Size: 1125 bytes --]

                 reply	other threads:[~2013-06-13 20:22 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=CAHZEYYOsJQFoWC8Je0k+xKHGxsfCAYe_v605unkop6_dAdi7HQ@mail.gmail.com \
    --to=nuffer@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).