4

I have a module Mod that is constrained by signature Sig. The module has a Nested sub-module. The signature has a matching Nested sub-signature:

module type Sig = sig
  val a : int
  module type Nested = sig
    val b : int
  end
end

module Mod : Sig = struct
  let a = 1
  module Nested = struct
    let b = 2
  end
end

However, this gives the following error:

Error: Signature mismatch: 
       Modules do not match: 
         sig val a : int module Nested : sig val b : int end end 
       is not included in 
         Sig 
       The field `Nested' is required but not provided

What am I missing?

IonuČ› G. Stan
  • 176,118
  • 18
  • 189
  • 202
Vladimir Keleshev
  • 13,753
  • 17
  • 64
  • 93

1 Answers1

7

The way of declaring the nested module was wrong in your code :

module type Sig = sig 
    val a : int 
    module Nested : sig val b : int end 
  end

module Mod : Sig = struct
  let a = 1
 module Nested = struct 
   let b = 2 
 end
end

Look how the submodules are declaring in the following link : http://caml.inria.fr/pub/docs/oreilly-book/html/book-ora131.html

It helps me to fix your error.

alifirat
  • 2,899
  • 1
  • 17
  • 33