For this one, the answer is interface documentation generation. The odoc tool does cross-referenced documentation, and is something we (@antron in particular) are actively working on to build a central docs.ocaml.org repository where the above interfaces could be browsed. As an example the current (beta) version of odoc running on the MirageOS modules and cross-referencing them can be found at http://docs.mirage.io.
As odoc gets more complete in the coming months, we’ll post on this forum to get your feedback on that.
Merlin should be able to show you all the relevant interfaces from within your editor. Have you given it a spin?
Yes, but it doesn’t work from emacs or the function that does it is buried somewhere and I couldn’t identify it. It works in Visual Studio Code (MIT license, runs on Linux/Mac/Windows) which I just tried out and it’s great.
Just in case you’re still wanting to stay at emacs world, the Merlin wiki of emacs from scratch documents the functions quite well, and you can use opam-user-setup to simplify the setup when using multiple switches. Or, in case readers are interested in Spacemacs, it’s only a matter of adding the ocaml layer (also includes Spacemacs installation instructions).
ok, so I found out what I was doing wrong. I had this in my .emacs:
; huh, C-c C-t is overridden by ocp-index-print-info-at-point,
; which kind of does the same thing but misses some type info.
(global-set-key (kbd "C-c t") 'merlin-type-enclosing)
which is probably wrong in more than one way. The main problem is that it overrides the original “C-c t” shortcut that would let me see the type of a module.
After commenting out the above, “C-c t” shows me the signature of the module under the cursor in another buffer, which is great. And “C-c C-t” is back to calling ocp-index-print-info-at-point which doesn’t fully work and often blocks for several seconds.
For the record, the problematic behavior happens after leaving just this in my ~/.emacs:
;; ## added by OPAM user-setup for emacs / base ## 56ab50dc8996d2bb95e7856a6eddb17b ## you can edit, but keep this line
(require 'opam-user-setup "~/.emacs.d/opam-user-setup.el")
;; ## end of OPAM user-setup addition for emacs / base ## keep this line
The instructions I think I followed and turned into a script for setting up emacs for OCaml development are: