What is the reason of separation of module implementation and signatures in OCaml?

I also personally like the clarity that comes from the separation.

That said, there are things that I find annoying about interface files:

  1. We can’t jump to a specific function implementation from interface (I think?).
  2. As a consequence of (1), we can’t jump to implementation from a documentation page.
  3. If you’re doing API-driven development, it would be nice to be able to automatically generate an .ml file with stub functions that satisfies the interface. A blog at Jane Street has a way to work around this but I think an editor support is nice to have.

I think .mli files could (and should), if present, be used as hints to do the .ml. Just like in Java where you say a class is implementing an interface, then the IDE would tell you that you’re missing an implementation of such-and-such methods.

4 Likes