* [Caml-list] Strange type error with recursive modules
@ 2013-06-13 20:22 Daniel Nuffer
0 siblings, 0 replies; only message in thread
From: Daniel Nuffer @ 2013-06-13 20:22 UTC (permalink / raw)
To: caml-list
[-- 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 --]
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2013-06-13 20:22 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-06-13 20:22 [Caml-list] Strange type error with recursive modules Daniel Nuffer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox