SearchPath
Isaac Jones
ijones at syntaxpolice.org
Wed May 18 13:07:31 EDT 2005
"S. Alexander Jacobson" <alex at alexjacobson.com> writes:
(snip)
> Things I'd like to know.
>
> 1. Is there a programmatic way to detect what packages are installed
> or do I have to shell out to ghc-pkg?
Yes. Cabal talks to ghc-pkg, you can use the
Distribution.Simple.Configure module for this, I think. Look around
for a function called "installedPackages" or something.
> 2. Is the name in the cabal file guaranteed to match the name exposed
> by ghc-pkg?
The package name in the cabal file is the same as the package name for
GHC.
> 3. Can I access the source of all exposed modules in an installed
> package to enumerate its external module dependencies and import
> chase?
Not the source of binary packages, but the .hi files have this
information, I believe.
> 4. If you have an unpacked package in a directory, is there a path
> from the cabal file to the relative paths of each file in the package?
> (so you can point at a repository rather than a tarball and access it
> via http).
Yeah. You can derive it from the module name plus the hs-source-dirs.
> 5. Given that module names are absolute, if you have another way to
> find external modules required by a package (e.g. SearchPath or
> perhaps hackage reverse lookup), can you ignore build-depends?
If you have an orthogonal system to do the same thing, of course you
can.
peace,
isaac
More information about the Libraries
mailing list