What is Oug ?

Oug is a code analysis tool building reference graphs from OCaml code, that is graphs representing which elements (value, module, class, ...) reference which elements. We will also call these graphs dependency graphs, each edge of the graph being annotated by a dependency kind.

It comes with the Ouglib library to be able to embed the analyzer in other OCaml applications.

From the graph, various outputs can be obtained: list of elements not referenced anywhere (useless elements and potential dead code), various Graphiz graphs, ...

Oug does not compute the call graph of the given OCaml code; this would require data flow analysis. For this reason, the "useless elements" dump always consider that every method is referenced.


See the downloads section to get Oug.

Then, follow the instructions in the INSTALL file coming with the distribution archive.


First read the usage section about how Oug works.

Have a look at some examples:

A quick guide to start using Oug on your code: Getting started.

The Filters section describe the filter language, used to find elements in the graph, with lots of examples.

The Ouglib library can be used to embed the analyzer in other OCaml applications. The reference documentation is here. The main module (oug.ml) of the oug tool uses this library and can be taken as example to use the library.

Maxence Guesdon: Fouille au code OCaml par analyse de dépendances
Journées Francophones des Langages Applicatifs 2009. [in french]

Oug is distributed under the GPL license.

Todo list

Here are some things to add:

  • handling of recursive modules,
  • a way to remember the use of alias module like A in
    module A = B
    By now, references to A.* point directly to elements of B. The "useless elements" dump filter empty modules not to display them as not referenced, so A appears to be used.