| Safe Haskell | None |
|---|---|
| Language | GHC2024 |
GHC.Unit.External.Database
Synopsis
- data ExternalUnitDatabases unit
- emptyExternalUnitDatabases :: ExternalUnitDatabases unit
- insertExternalUnitDatabases :: UnitDatabase unit -> ExternalUnitDatabases unit -> ExternalUnitDatabases unit
- deleteExternalUnitDatabases :: OsPath -> ExternalUnitDatabases unit -> ExternalUnitDatabases unit
- lookupExternalUnitDatabases :: OsPath -> ExternalUnitDatabases unit -> Maybe (UnitDatabase unit)
- data UnitDatabase unit = UnitDatabase {
- unitDatabasePath :: OsPath
- unitDatabaseUnits :: [GenUnitInfo unit]
- mergeDatabases :: Logger -> [UnitDatabase UnitId] -> IO (UnitInfoMap, UnitPrecedenceMap)
- type UnitPrecedenceMap = UniqMap UnitId Int
- sortByPreference :: UnitPrecedenceMap -> [UnitInfo] -> [UnitInfo]
- compareByPreference :: UnitPrecedenceMap -> UnitInfo -> UnitInfo -> Ordering
- data UnitDbConfig = UnitDbConfig {}
- readUnitDatabase :: Logger -> UnitDbConfig -> OsPath -> IO (UnitDatabase UnitId)
- getUnitDbRefs :: UnitDbConfig -> IO [PkgDbRef]
- resolveUnitDatabase :: UnitDbConfig -> PkgDbRef -> IO (Maybe OsPath)
ExternalUnitDatabases
data ExternalUnitDatabases unit Source #
Caches unit databases in-memory.
insertExternalUnitDatabases :: UnitDatabase unit -> ExternalUnitDatabases unit -> ExternalUnitDatabases unit Source #
deleteExternalUnitDatabases :: OsPath -> ExternalUnitDatabases unit -> ExternalUnitDatabases unit Source #
lookupExternalUnitDatabases :: OsPath -> ExternalUnitDatabases unit -> Maybe (UnitDatabase unit) Source #
UnitDatabase and how to merge them.
data UnitDatabase unit Source #
Unit database entry.
Constructors
| UnitDatabase | |
Fields
| |
Instances
| Outputable u => Outputable (UnitDatabase u) Source # | |
Defined in GHC.Unit.External.Database Methods ppr :: UnitDatabase u -> SDoc Source # | |
mergeDatabases :: Logger -> [UnitDatabase UnitId] -> IO (UnitInfoMap, UnitPrecedenceMap) Source #
Given a list of databases, merge them together, where
units with the same unit id in later databases override
earlier ones. This does NOT check if the resulting database
makes sense (that's done by validateDatabase).
type UnitPrecedenceMap = UniqMap UnitId Int Source #
For each unit, a mapping from uid -> i indicates that this
unit was brought into GHC by the ith -package-db flag on
the command line. We use this mapping to make sure we prefer
units that were defined later on the command line, if there
is an ambiguity.
sortByPreference :: UnitPrecedenceMap -> [UnitInfo] -> [UnitInfo] Source #
This sorts a list of packages, putting "preferred" packages first.
See compareByPreference for the semantics of "preference".
compareByPreference :: UnitPrecedenceMap -> UnitInfo -> UnitInfo -> Ordering Source #
Returns GT if pkg should be preferred over pkg' when picking
which should be "active". Here is the order of preference:
- First, prefer the latest version
- If the versions are the same, prefer the package that came in the latest package database.
Pursuant to #12518, we could change this policy to, for example, remove the version preference, meaning that we would always prefer the units in later unit database.
Reading packages from disk.
data UnitDbConfig Source #
Constructors
| UnitDbConfig | |
readUnitDatabase :: Logger -> UnitDbConfig -> OsPath -> IO (UnitDatabase UnitId) Source #
Read the UnitDatabase at the given location.
getUnitDbRefs :: UnitDbConfig -> IO [PkgDbRef] Source #
resolveUnitDatabase :: UnitDbConfig -> PkgDbRef -> IO (Maybe OsPath) Source #
Return the path of a package database from a PkgDbRef. Return Nothing
when the user database filepath is expected but the latter doesn't exist.
NB: This logic is reimplemented in Cabal, so if you change it, make sure you update Cabal. (Or, better yet, dump it in the compiler info so Cabal can use the info.)