#1463: Module → Package lookup in ghc-pkg?
----------------------------------+-----------------------------------------
Reporter: [EMAIL PROTECTED] | Owner:
Type: feature request | Status: new
Priority: normal | Milestone:
Component: Compiler | Version: 6.6.1
Severity: normal | Resolution:
Keywords: | Difficulty: Unknown
Os: Unknown | Testcase:
Architecture: Unknown |
----------------------------------+-----------------------------------------
Comment (by claus):
i, too, would like to be able to get more information about installed
packages more easily: see the end of http://www.haskell.org/pipermail
/haskell-cafe/2007-March/023150.html
however, hoogle would only be one of many tools making use of this kind of
index, and i think the functionality is better located in ghc-pkg/cabal.
in fact, i thought it should be one of the things cabal ought to be good
at, but looking through the haddocks for Distribution.*, i seem to be
running around in circles: is there any standard way to get at the
installed package.conf files, or directly at the InstalledPackageInfos?
there's a getInstalledPackages, but that only gives me the
PackageIdentifiers, with no obvious way to go further?
i only started to make progress when i abandoned cabal and focussed on its
data structures. here's a quick hack, i'd appreciate suggestions on how to
overcome its obvious limitations:
{{{
import Distribution.Simple.Configure
import Distribution.Simple
import Distribution.InstalledPackageInfo
import System.FilePath
getInfo packageName = do
Just ghc <- findProgram "ghc" Nothing
let ghcDir = takeDirectory $ takeDirectory ghc -- drop bin/ghc[.exe]
conf <- readFile (ghcDir </> "package.conf") -- how to get this path?
let infos = (read conf :: [InstalledPackageInfo])
return [ (name, exposedModules info, haddockHTMLs info)
| info <- infos
, let name = pkgName (package info)
, name == packageName ]
}}}
example output:
{{{
*Main> getInfo "haskell-src"
[("haskell-
src",["Language.Haskell.Lexer","Language.Haskell.Parser","Language.Ha
skell.ParseMonad","Language.Haskell.ParseUtils","Language.Haskell.Pretty","Langu
age.Haskell.Syntax"],["$topdir\\html\\libraries\\haskell-src"])]
}}}
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/1463>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs