need ghc-pkg dump feature
Cabal already needs quite a bit of information from ghc-pkg about the package database. In the future we would like even more information. It would be more efficient for Cabal to ask ghc-pkg once for all the information rather than to ask lots of little questions. (ghc-pkg is quite slow when lots of packages are registered)
For each package we want to know it's name, version, what packages it depends on, any C flags or include dirs, the exposed modules, the haddock html & interface dir.
We also need to be able to ask this information for a specific package database and get results for only that db. This is because Cabal needs to distinguish global and user packages. In future when we want to build several packages inplace we'll also want to use specific inplace package dbs.
So a dump command should probably just describe every package in a specified db. We already know how to parse an InstalledPackageDescription which is the format that ghc-pkg describe produces. One potential problem is distinguishing package boundaries if all the package descriptions are concatenated. Perhaps something simple like a blank line would suffice.
So here's a concrete suggestion:
ghc-pkg dump --global
should produce the concatenation (with blank line separators) of
ghc-pkg describe for each package in the global package db. Note that is should list only those packages in the global db, not those from the user db.
ghc-pkg dump --user ghc-pkg dump --package-conf=foo.package.conf
So these should do similarly, but act only upon the specified package dbs.