In object-oriented programming, the class diagram is a very popular way to show the structure of the system. (Perhaps at this point I should emphasize that this question is not about objects etc.)
In OCaml, we have module types, modules and functors. We can refine module types using e.g. “with type” annotations or similar. Refinement is in some ways similar to subtyping.
Is there any way to capture the relationships (including refinement) between module types, modules and functors in a diagram, analogous to a class diagram?
My hope is that this might make some things more easy to understand. For example, the chapter on modules here:
More seriously, traditional UML-y class diagrams should work for modules, but pretty much nobody uses such a constrained format. You can find diagrams in some contexts (this for example) but it’s usually simpler to just write down the relations and follow the typechecker.
I created a single file called “recapitulation.ml”, where I reference all the main modules, functors, module types, etc. Not a diagram, but usefully collects the main types in a single place.
I’d like to write something like:
module type X = Foo.X = sig … end
(Analogous to type t = X.t = … ?)
This would allow the file to be reasonably self-contained (at the moment, I have to look at the file foo.ml at least). Is there anything like this?