← Back to index

How to implement module recursion in ReScript?

Thu Dec 02 2021

ReScript version: rescript@9.1.4
module type X = {
  let x: unit => int
  let y: unit => int
}

module rec A: X = {
  let x = () => 1
  let y = () => B.y() + 1
}
and B: X = {
  let x = () => A.x() + 2
  let y = () => 2
}