Expose ghc-pkg internals as a library
The module GHC.PackageDb, which is in the ghc-boot
package and therefore shipped alongside base
, and which exposes the crucial data type InstalledPackageInfo a b c d e f g
and functions readPackageDbForGhc
, readPackageDbForGhcPkg
, and writePackageDb
, is nonetheless crippled outside of GHC:
-
The first function requires instances of the
BinaryStringRep
andDbUnitIdModuleRep
classes, which do not have any in any public package -
The second one uses a polymorphic parameter that, in order to run without error, actually needs to be Distribution.InstalledPackageInfo, defined in the completely different
Cabal
package neither mentioning nor mentioned byghc-boot
-
The third one takes two arguments of which the first (a list of
InstalledPackageInfo a b c d e f g
) is redundant because it can be constructed from the second, but no conversion function is defined.
While it is possible to write both the instances and conversion function by hand, it is extremely awkward and I worry that it is also fragile, given the internal nature of this entire module.
The full functionality of this package is only available within the Main module of ghc-pkg
, which is highly monolithic despite containing such generally useful code as the above instances and conversion function. Since GHC.PackageDb
provides so much of ghc-pkg
's essential functionality as a library, it seems reasonable to request that this code be brought out of the opaque Main
module and into a public library. I understand from the comments that ghc-boot
is not the place for this, but perhaps one of the following is:
a. Cabal
, because it already has the InstalledPackageInfo
(no parameters) type used by ghc-pkg
; however, Cabal
seems committed to calling ghc-pkg
as an executable, not providing linkage to its internals.
b. a separate ghc-pkg
library containing, possibly, a more carefully chosen selection of that executable's code.
Trac metadata
Trac field | Value |
---|---|
Version | 8.2.2 |
Type | FeatureRequest |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | Core Libraries |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | |
Operating system | |
Architecture |