简体   繁体   中英

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 ?

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 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM