diff options
author | Edward Z. Yang <ezyang@cs.stanford.edu> | 2016-10-06 13:40:10 -0700 |
---|---|---|
committer | Edward Z. Yang <ezyang@cs.stanford.edu> | 2016-10-08 01:37:56 -0700 |
commit | 5bd8e8d30c046187f2804db3af1768ea8b07dc41 (patch) | |
tree | ecea3d97b4599e19893ff8b9ca6da3c51066b27b /utils | |
parent | 4e8a0607140b23561248a41aeaf837224aa6315b (diff) | |
download | haskell-5bd8e8d30c046187f2804db3af1768ea8b07dc41.tar.gz |
Make InstalledUnitId be ONLY a FastString.
It turns out that we don't really need to be able to
extract a ComponentId from UnitId, except in one case.
So compress UnitId into a single FastString.
The one case where we do need the ComponentId is when
we are compiling an instantiated version of a package;
we need the ComponentId to look up the indefinite
version of this package from the database. So now we
just pass it in as an argument -this-component-id.
Also: ghc-pkg now no longer will unregister a package if
you register one with the same package name, if the
instantiations don't match.
Cabal submodule update which tracks the same data type
change.
Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
Diffstat (limited to 'utils')
-rw-r--r-- | utils/ghc-pkg/Main.hs | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/utils/ghc-pkg/Main.hs b/utils/ghc-pkg/Main.hs index c0474423de..4466f58878 100644 --- a/utils/ghc-pkg/Main.hs +++ b/utils/ghc-pkg/Main.hs @@ -998,7 +998,9 @@ registerPackage input verbosity my_flags multi_instance removes = [ RemovePackage p | not multi_instance, p <- packages db_to_operate_on, - sourcePackageId p == sourcePackageId pkg ] + sourcePackageId p == sourcePackageId pkg, + -- Only remove things that were instantiated the same way! + instantiatedWith p == instantiatedWith pkg ] -- changeDB verbosity (removes ++ [AddPackage pkg]) db_to_operate_on @@ -1098,6 +1100,7 @@ convertPackageInfoToCacheFormat :: InstalledPackageInfo -> PackageCacheFormat convertPackageInfoToCacheFormat pkg = GhcPkg.InstalledPackageInfo { GhcPkg.unitId = installedUnitId pkg, + GhcPkg.componentId = installedComponentId pkg, GhcPkg.instantiatedWith = instantiatedWith pkg, GhcPkg.sourcePackageId = sourcePackageId pkg, GhcPkg.packageName = packageName pkg, @@ -1147,22 +1150,20 @@ instance GhcPkg.BinaryStringRep String where toStringRep = BS.pack . toUTF8 instance GhcPkg.BinaryStringRep UnitId where - fromStringRep = fromMaybe (error "BinaryStringRep UnitId") - . simpleParse . fromStringRep + fromStringRep = mkUnitId . fromStringRep toStringRep = toStringRep . display -instance GhcPkg.DbUnitIdModuleRep ComponentId OpenUnitId ModuleName OpenModule where +instance GhcPkg.DbUnitIdModuleRep UnitId ComponentId OpenUnitId ModuleName OpenModule where fromDbModule (GhcPkg.DbModule uid mod_name) = OpenModule uid mod_name fromDbModule (GhcPkg.DbModuleVar mod_name) = OpenModuleVar mod_name toDbModule (OpenModule uid mod_name) = GhcPkg.DbModule uid mod_name toDbModule (OpenModuleVar mod_name) = GhcPkg.DbModuleVar mod_name fromDbUnitId (GhcPkg.DbUnitId cid insts) = IndefFullUnitId cid (Map.fromList insts) - fromDbUnitId (GhcPkg.DbInstalledUnitId cid bs) - = DefiniteUnitId (unsafeMkDefUnitId (UnitId cid (fmap fromStringRep bs))) + fromDbUnitId (GhcPkg.DbInstalledUnitId uid) + = DefiniteUnitId (unsafeMkDefUnitId uid) toDbUnitId (IndefFullUnitId cid insts) = GhcPkg.DbUnitId cid (Map.toList insts) toDbUnitId (DefiniteUnitId def_uid) - | UnitId cid mb_hash <- unDefUnitId def_uid - = GhcPkg.DbInstalledUnitId cid (fmap toStringRep mb_hash) + = GhcPkg.DbInstalledUnitId (unDefUnitId def_uid) -- ----------------------------------------------------------------------------- -- Exposing, Hiding, Trusting, Distrusting, Unregistering are all similar |