Dependency visualization

You can use stack to visualize the dependencies between your packages and optionally also external dependencies.

First, you need Graphviz. You can get it here.

As an example, let's look at wreq:

$ stack dot | dot -Tpng -o wreq.png


Okay that is a little boring, let's also look at external dependencies:

$ stack dot --external | dot -Tpng -o wreq.png


Well that is certainly a lot. As a start we can exclude base and then depending on our needs we can either limit the depth:

$ stack dot --no-include-base --external --depth 1 | dot -Tpng -o wreq.png


or prune packages explicitly:

$ stack dot --external --prune base,lens,wreq-examples,http-client,aeson,tls,http-client-tls,exceptions | dot -Tpng -o wreq_pruned.png


Keep in mind that you can also save the dot file:

$ stack dot --external --depth 1 >
$ dot -Tpng -o wreq.png

and pass in options to dot or use another graph layout engine like twopi:

$ stack dot --external --prune base,lens,wreq-examples,http-client,aeson,tls,http-client-tls,exceptions | twopi -Groot=wreq -Goverlap=false -Tpng -o wreq_pruned.png


Specifying local targets and flags

The dot and list-dependencies commands both also accept the following options which affect how local packages are considered:

  • TARGET, same as the targets passed to build
  • --test, specifying that test components should be considered
  • --bench, specifying that benchmark components should be considered
  • --flag, specifying flags which may affect cabal file build-depends