[Haskell-cafe] How to know the build dependencies?

Claus Reinke claus.reinke at talk21.com
Sun Jun 14 06:24:44 EDT 2009


>  I am learning to use cabal for my code.
>  Just when I start, I met a question, is there an easy way to find
> out what packages my code depends?

If you've managed to get your code to compile,

    ghc --show-iface Main.hi

is perhaps the easiest way (ghc --make and ghci will also report 
package dependencies as they encounter them).

If you're looking for the package for a particular module, ghc-pkg
can help

    ghc-pkg find-module Control.Concurrent
    c:/ghc/ghc-6.10.3\package.conf:
        base-3.0.3.1, base-4.1.0.0

    ghc-pkg find-module Data.Map
    c:/ghc/ghc-6.10.3\package.conf:
        containers-0.2.0.1

If you're looking for a minimal set of imports before hunting for 
packages, ghc's -ddump-minimal-imports will create a file Main.imports 
with that information. You could then run ghc-pkg find-module over
that list.

These are not the only options. Perhaps the available tools 
need to be advertized more?-)

Claus




More information about the Haskell-Cafe mailing list