I wrote up this little example of recursive modules:
module rec A : sig
type t
val a_fn : t -> B.t
val of_float : float -> t
end = struct
type t = int
let a_fn x = B.of_int x
let of_float x = int_of_float x
end
and B : sig
type t val
another_fn : t -> A.t
val of_int : int -> t
end = struct
type t = float
let another_fn x = A.of_float x
let of_int x = float_of_int x
end
It works, though I’m not sure it does what you’re looking for:
# A.a_fn (A.of_float 14.0);;
- : B.t = <abstr>
# B.another_fn (B.of_int 122);;
- : A.t = <abstr>