Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in / Register
GHC
GHC
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 4,334
    • Issues 4,334
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
    • Iterations
  • Merge Requests 368
    • Merge Requests 368
  • Requirements
    • Requirements
    • List
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
  • Security & Compliance
    • Security & Compliance
    • Dependency List
    • License Compliance
  • Operations
    • Operations
    • Incidents
    • Environments
  • Analytics
    • Analytics
    • CI / CD
    • Code Review
    • Insights
    • Issue
    • Repository
    • Value Stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Collapse sidebar
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
  • Glasgow Haskell Compiler
  • GHCGHC
  • Issues
  • #15129

Closed
Open
Opened May 07, 2018 by ryanreich@trac-ryanreich

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 and DbUnitIdModuleRep 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 by ghc-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
Assignee
Assign to
None
Milestone
None
Assign milestone
Time tracking
None
Due date
None
Reference: ghc/ghc#15129