Types 如何在OCaml中定义两个相互链接的模块?

Types 如何在OCaml中定义两个相互链接的模块?,types,module,ocaml,Types,Module,Ocaml,我知道我们可以定义两种相互链接的类型,例如: type a = | CC of b and b = | CD of a 有人知道如何对两个模块执行相同的操作吗 module A = struct type t = | CC of B.t end ?and? B = struct type t = | CD of A.t end 它被称为OCaml。不幸的是,您必须编写两次类型声明 module rec A: sig type t = | CC of B.t end

我知道我们可以定义两种相互链接的类型,例如:

type a =
   | CC of b

and b =
   | CD of a
有人知道如何对两个模块执行相同的操作吗

module A = struct
  type t = | CC of B.t
end

?and? B = struct
  type t = | CD of A.t
end
它被称为OCaml。不幸的是,您必须编写两次类型声明

module rec A: sig
  type t = | CC of B.t
end = 
struct  
  type t = | CC of B.t
end

and B: sig 
  type t = | CD of A.t
end = 
struct
  type t = | CD of A.t
end