Haskell Packages - Dependency Tree

In the java - maven build tool, you can print the dependency tree for any package/project with the command

 mvn dependency:tree -Dverbose -Dincludes=commons-collections 

and the output will be a tree structure of artifacts/dependencies like,

 [INFO] [dependency:tree] [INFO] org.apache.maven.plugins:maven-dependency-plugin:maven-plugin:2.0-alpha-5-SNAPSHOT [INFO] +- org.apache.maven.reporting:maven-reporting-impl:jar:2.0.4:compile [INFO] | \- commons-validator:commons-validator:jar:1.2.0:compile [INFO] | \- commons-digester:commons-digester:jar:1.6:compile [INFO] | \- (commons-collections:commons-collections:jar:2.1:compile - omitted for conflict with 2.0) [INFO] \- org.apache.maven.doxia:doxia-site-renderer:jar:1.0-alpha-8:compile [INFO] \- org.codehaus.plexus:plexus-velocity:jar:1.1.3:compile [INFO] \- commons-collections:commons-collections:jar:2.0:compile 

So how can I do this for a haskell package using cabal ?

+8
haskell cabal
source share
2 answers

A graph containing all installed packages can be created using ghc-pkg , for example

 ghc-pkg dot | tred | dot -Tpdf >pkgs.pdf 

Note that the graphviz package provides tred and the dot program.

+14
source share

For the installed package, you can find the dependencies using ghc-pkg . For a package named text you need to do:

 $ ghc-pkg field text depends depends: array-0.5.0.0-470385a50d2b78598af85cfe9d988e1b base-4.7.0.2-bfd89587617e381ae01b8dd7b6c7f1c1 bytestring-0.10.4.0-d6f1d17d717e8652498cab8269a0acd5 deepseq-1.3.0.2-63a1ab91b7017a28bb5d04cb1b5d2d02 ghc-prim-0.3.1.0-a24f9c14c632d75b683d0f93283aea37 integer-gmp-0.5.1.0-26579559b3647acf4f01d5edd9491a46 

For any working project, all you have to do is see the depends field in the cabal file to determine its dependency.

+2
source share

All Articles