I know that it is possible to define recursive modules, does anyone know how to define recursive signatures? For instance, I would like to realize:
module type AAA = sig
module Bbb : BBB
type 'a t
val f : 'a Bbb.t -> 'a t
end
module type BBB = sig
module Aaa : AAA
type 'a t
val g : 'a Aaa.t -> 'a t
end
Could anyone help?
You can’t, as far as I can tell. The closest solution is to limit the “recursive” bits to what is actually needed to express each signature separately:
And then refine when you define the modules:
FWIW, one might think that it should be possible to express recursive signatures (with much repetition) by using recursive modules:
However, that does not work: