Version française
Home     About     Download     Resources     Contact us    
Browse thread
Another question about modules
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Andre Nathan <andre@d...>
Subject: Another question about modules
Hello

I'm having an issue that is similar to the one reproduced in the code
below:

a.ml:

module SubA :
  sig
    type t
    val f : t -> unit
    val id : t -> int
  end =
  struct
    type t = { id: int }
    let f = B.f
    let id x = x.id
  end

a.mli:

module SubA :
  sig
    type t
    val f : t -> unit
    val id : t -> int
  end

b.ml:

open A
let f x = print_int (SubA.id x)

b.mli:

open A
val f : SubA.t -> unit


When I compile this, I get the following message:

File "a.ml", line 7, characters 2-75:
Signature mismatch:
Modules do not match:
  sig type t = { id : int; } val f : A.SubA.t -> unit val id : t -> int
end
is not included in
  sig type t val f : t -> unit val id : t -> int end
Values do not match:
  val f : A.SubA.t -> unit
is not included in
  val f : t -> unit


Shouldn't "t" (from A.SubA) and A.SubA.t be recognized as the same type
here? I don't understand why they aren't. Is there any workaround for
this issue or is this kind of thing (yet again) a sign that there's
something fishy in my design?

Thanks in advance,
Andre