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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With