Visualizing dependencies between Ocaml modules

Hi,

I am trying to understand a (more or less large) Ocaml project with lot of files and modules.
I am particularly interested, as a first step, in understanding the interfaces theses modules expose and how theses interfaces are used. I believe an UML component diagram would help with this.

My question is : Is there any tool that can generate the component diagram from Ocaml code?
I have in the past worked with a tool called Moose (http://moosetechnology.org/) that not only generates visualization of OO source code but also allows one to make queries and interact with diagrams to navigate specific aspects of the code. I wonder if such a tool exists for Ocaml (or more broadly, functional) code.

I have two answers that are likely not quite what you asked for, but I hope you find them relevant regardless.

At Robur we use opam-graph to generate visualizations for dependencies at opam package level. You can look at an example for this build (the top visualization): https://builds.robur.coop/job/opam-graph/build/f4823163-eaae-4ce1-9bd2-60261f930392

We also use modulectomy (or rather a fork) originally created by @Drup to visualize OCaml binary size as contributed by different OCaml modules. See for example the second visualization here: Job miragevpn-server 2024-09-05 15:27:23Z

2 Likes

I’ll use this opportunity to plug my own tool: GitHub - sim642/odep: Dependency graphs for OCaml modules, libraries and packages. It can do visualizations at various levels: dune modules, findlib libraries and opam packages.
At the end of odep’s README I have a list of various other tools I’ve found and how they differ.

6 Likes

This post really drives the point home that I’m a bad maintainer, all my funky weird experiments end up adopted and maintained by someone else :sweat_smile:

@sim642 Well done, that tool looks amazing !
@reynir Maybe we should do some github shenanigans to make your repository the main one. :slight_smile: