[Question] How to use circular references of types

I ran into some problems when trying to reference different modules in the same folder:

I noticed the and keyword, but it doesn’t seem to work:

module rec A = {
  type a = {
    b: B.b
  }
}
and module B = {
  type b = {
    a: A.a
  } 
}

Splitting it into two files solves the problem, but I’d like to know what to do with different modules under the same file.

You have to annotate recursive modules with explicit types:


module rec A: {
  type a = {b: B.b}
} = {
  type a = {b: B.b}
}
and B: {
  type b = {a: A.a}
} = {
  type b = {a: A.a}
}
3 Likes

Specifically what doesn’t work? Can you give any details?

It was caused by my incorrect use of and syntax