My current project uses AST with 40 different types (discriminated unions) and several types from this AST has cyclic dependency.
The types are not so big, therefore I put them in one file and applied type ... and ...
construction for mutually dependent types.
Now, I'm adding functions to make some calculations under each element in AST. Since, there are a lot of functions with several lines of code in them, to make source code cleaner to read, I've separated these functions in different files.
It's Ok in the case when cyclic dependency is absent, also works when dependent functions are in the same file - in this case I can use let rec function1 ... and function2 ...
construction.
But it will not work in my case.
Also, I incorrectly thought that signature files can help me with this, but their behavior differs from C++
- they are used to define functions/types access mode (internal/public), also functions/types comment header can be added here.
The only possible solution I see is to move all functions to one file and use let rec ... and ... and ... and ... and ...
construction.
Possible somebody has different ideas?