Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Generating Haskell module dependency tree

Tags:

haskell

Is there a way I could generate (and view) the module dependency tree of my Haskell project? I've seen images of such graphs but am unable to dlfigure out how it could be done.

like image 410
Petras Purlys Avatar asked Dec 23 '22 15:12

Petras Purlys


2 Answers

For Haskell stack, you can let stack write a GraphViz dot file for the dependency graph with:

stack dot --external

The --external flag means it will include dependencies not defined in your stack project. You can for example use I/O redirection to write it to a file with:

stack dot --external > deps.dot

and then use dot as a tool to convert this to an image, for example with:

dot -Tpng deps.dot -odeps.png

You can also make use of -Tsvg, -Tgif, etc. to pick another image format.

For more information, see the dependency visualization section of the documentation.

like image 111
Willem Van Onsem Avatar answered Jan 02 '23 11:01

Willem Van Onsem


You can get a graph of a project's modules with yav/graphmod:

cabal install graphmod

The in your project:

~/.cabal/bin/graphmod | dot -Tpng > modules.png

You can see more options with ~/.cabal/bin/graphmod --help, change the output format with options to dot, and see examples here.

like image 45
avh4 Avatar answered Jan 02 '23 09:01

avh4