Referring to mutually recursive modules

The problem is with

module rec Eff : sig
  type 'a t = ...
  val map : ('a -> 'b) -> 'a t -> 'b t
end = struct .. end
and module Program : (S with Eff = Eff) = Make(Eff)

The module-checker considers that mentioning the recursively-defined Eff directly in the signature of Program is unsafe. I’m not sure why, but I think that it may come from the fact that Eff also has value components. In contrast, mentioning type components of Eff is safe, so the following works:

module rec Eff : sig
  type 'a t = ...
  val map : ('a -> 'b) -> 'a t -> 'b t
end = struct .. end
and module Program : (S with 'a Eff.t = 'a Eff.t) = Make(Eff)
3 Likes