Steakfly
Steakfly

Reputation: 467

Type constraint for module inclusion in OCaml

I want to define the following module hierarchy, but it does not work :

module type A = sig
    type t
end

module type B = sig
    type u
    include A
end

module type C = sig
    (* Error: Unbound type constructor u *)
    include B with type t = u list
end

Why is there an error regarding type u ?

Upvotes: 2

Views: 211

Answers (1)

Drup
Drup

Reputation: 3739

The types after the = should be available outside of the module you are trying to include/modify.

Here, you would do :

module type C = sig
  type u 
  include B with type u := u and type t = u list
end 

Upvotes: 5

Related Questions