Consider the following snippet
open Bin_prot.Std
module rec A: sig
type t = C of string
| D of B.t [@@deriving bin_io]
end = struct
type t = C of string
| D of B.t [@@deriving bin_io]
end and B: sig
type t = E of string
| F of B.t [@@deriving bin_io]
end = struct
type t = E of string
| F of B.t [@@deriving bin_io]
end
Attempting to build it fails with an error
Error: Cannot safely evaluate the definition of the following cycle
of recursively-defined modules: B -> B. There are no safe modules
in this cycle (see manual section 10.2).
Right. Digging a bit deeper, I can reproduce the error just with [@@deriving bin_shape] or [@@deriving bin_read] or [@@deriving bin_write].
I understand why bin_shapecauses this error (there’s obviously a conflict in evaluation order), not so sure why bin_read or bin_write do.
So, what should I do? I suppose I could hand-roll the (de)serializers for my modules (in my actual code, I have 3 mutually recursive modules and a dozen types), but this doesn’t seem very optimal.