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.
CodePudding user response:
For cabal you can use the cabal-plan
executable to generate a dependency graph. First install cabal-plan
with:
cabal install cabal-plan
Then you can go to your cabal package directory and run:
cabal-plan dot | dot -Tpdf -odeps.pdf
(You have to run cabal build
or cabal configure
first if you have not done so already)
This will produce a dependency graph in PDF form in the file deps.pdf
.
CodePudding user response:
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.