[Haskell-cafe] Listing package dependencies from GHC

Dougal Stanton ithika at gmail.com
Thu May 3 10:35:57 EDT 2007


On 03/05/07, Thomas Schilling <nominolo at googlemail.com> wrote:

>
> I once used this perl script to determine the files I was actually
> used (to have proper LOC stats).  It uses ghc -M which usually
> outputs the dependencies as makefile targets, and then grep over this
> to get all the .hs files.  If you have different file types you might
> want to modify this:

Sorry, maybe I didn't express myself properly. By dependencies I
meant, library packages that GHC knows about.

For example, if I load something simple like

> import System.Posix.Files
> main = touchFile "example"

into GHCi and execute ":main" it prints

> Loading package unix-1.0 ... linking ... done.

But if I try the same by compiling with a ./Setup build (ie cabal) the
build system complains that it "could not find X, it is a member of
unix".

My problem is that the only way I can get from a template cabal file
to a fully working one is by iteration - add dependency to
"Build-depends", recompile, fail, repeat.

It's obvious GHC knows how to find all the right dependencies. It does
it in GHCi. It can even be done from the command line with "--make".
But can I get it to *tell* me the information that cabal needs?

Cheers,

Dougal.


More information about the Haskell-Cafe mailing list