diff options
author | Sylvain Henry <sylvain@haskus.fr> | 2020-01-15 17:48:30 +0100 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2020-01-31 02:46:15 -0500 |
commit | 29c701c154cafa4844cf3c1bd4a93cacfa6b1ee1 (patch) | |
tree | 88a060f43c73306463510b53607c1fd9460bd84b /compiler/basicTypes | |
parent | bf38a20eefcaaaac404a1818c3eff8273dc67dd9 (diff) | |
download | haskell-29c701c154cafa4844cf3c1bd4a93cacfa6b1ee1.tar.gz |
Refactor package related code
The package terminology is a bit of a mess. Cabal packages contain
components. Instances of these components when built with some
flags/options/dependencies are called units. Units are registered into
package databases and their metadata are called PackageConfig.
GHC only knows about package databases containing units. It is a sad
mismatch not fixed by this patch (we would have to rename parameters
such as `package-id <unit-id>` which would affect users).
This patch however fixes the following internal names:
- Renames PackageConfig into UnitInfo.
- Rename systemPackageConfig into globalPackageDatabase[Path]
- Rename PkgConfXX into PkgDbXX
- Rename pkgIdMap into unitIdMap
- Rename ModuleToPkgDbAll into ModuleNameProvidersMap
- Rename lookupPackage into lookupUnit
- Add comments on DynFlags package related fields
It also introduces a new `PackageDatabase` datatype instead of
explicitly passing the following tuple: `(FilePath,[PackageConfig])`.
The `pkgDatabase` field in `DynFlags` now contains the unit info for
each unit of each package database exactly as they have been read from
disk. Previously the command-line flag `-distrust-all-packages` would
modify these unit info. Now this flag only affects the "dynamic"
consolidated package state found in `pkgState` field. It makes sense
because `initPackages` could be called first with this
`distrust-all-packages` flag set and then again (using ghc-api) without
and it should work (package databases are not read again from disk when
`initPackages` is called the second time).
Bump haddock submodule
Diffstat (limited to 'compiler/basicTypes')
-rw-r--r-- | compiler/basicTypes/Module.hs | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/compiler/basicTypes/Module.hs b/compiler/basicTypes/Module.hs index eb5452e6a8..4cd69b786b 100644 --- a/compiler/basicTypes/Module.hs +++ b/compiler/basicTypes/Module.hs @@ -170,7 +170,7 @@ import qualified FiniteMap as Map import System.FilePath import {-# SOURCE #-} DynFlags (DynFlags) -import {-# SOURCE #-} Packages (componentIdString, improveUnitId, PackageConfigMap, getPackageConfigMap, displayInstalledUnitId) +import {-# SOURCE #-} Packages (componentIdString, improveUnitId, UnitInfoMap, getUnitInfoMap, displayInstalledUnitId) -- Note [The identifier lexicon] -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -642,7 +642,7 @@ indefUnitIdToUnitId dflags iuid = -- p[H=impl:H]. If we *only* wrap in p[H=impl:H] -- IndefiniteUnitId, they won't compare equal; only -- after improvement will the equality hold. - improveUnitId (getPackageConfigMap dflags) $ + improveUnitId (getUnitInfoMap dflags) $ IndefiniteUnitId iuid data IndefModule = IndefModule { @@ -943,18 +943,18 @@ type ShHoleSubst = ModuleNameEnv Module -- @p[A=<A>]:B@ maps to @p[A=q():A]:B@ with @A=q():A@; -- similarly, @<A>@ maps to @q():A@. renameHoleModule :: DynFlags -> ShHoleSubst -> Module -> Module -renameHoleModule dflags = renameHoleModule' (getPackageConfigMap dflags) +renameHoleModule dflags = renameHoleModule' (getUnitInfoMap dflags) -- | Substitutes holes in a 'UnitId', suitable for renaming when -- an include occurs; see Note [Representation of module/name variable]. -- -- @p[A=<A>]@ maps to @p[A=<B>]@ with @A=<B>@. renameHoleUnitId :: DynFlags -> ShHoleSubst -> UnitId -> UnitId -renameHoleUnitId dflags = renameHoleUnitId' (getPackageConfigMap dflags) +renameHoleUnitId dflags = renameHoleUnitId' (getUnitInfoMap dflags) --- | Like 'renameHoleModule', but requires only 'PackageConfigMap' +-- | Like 'renameHoleModule', but requires only 'UnitInfoMap' -- so it can be used by "Packages". -renameHoleModule' :: PackageConfigMap -> ShHoleSubst -> Module -> Module +renameHoleModule' :: UnitInfoMap -> ShHoleSubst -> Module -> Module renameHoleModule' pkg_map env m | not (isHoleModule m) = let uid = renameHoleUnitId' pkg_map env (moduleUnitId m) @@ -963,9 +963,9 @@ renameHoleModule' pkg_map env m -- NB m = <Blah>, that's what's in scope. | otherwise = m --- | Like 'renameHoleUnitId, but requires only 'PackageConfigMap' +-- | Like 'renameHoleUnitId, but requires only 'UnitInfoMap' -- so it can be used by "Packages". -renameHoleUnitId' :: PackageConfigMap -> ShHoleSubst -> UnitId -> UnitId +renameHoleUnitId' :: UnitInfoMap -> ShHoleSubst -> UnitId -> UnitId renameHoleUnitId' pkg_map env uid = case uid of (IndefiniteUnitId @@ -975,7 +975,7 @@ renameHoleUnitId' pkg_map env uid = -> if isNullUFM (intersectUFM_C const (udfmToUfm (getUniqDSet fh)) env) then uid -- Functorially apply the substitution to the instantiation, - -- then check the 'PackageConfigMap' to see if there is + -- then check the 'UnitInfoMap' to see if there is -- a compiled version of this 'UnitId' we can improve to. -- See Note [UnitId to InstalledUnitId] improvement else improveUnitId pkg_map $ |