summaryrefslogtreecommitdiff
path: root/compiler/main/PackageConfig.hs
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/main/PackageConfig.hs')
-rw-r--r--compiler/main/PackageConfig.hs23
1 files changed, 10 insertions, 13 deletions
diff --git a/compiler/main/PackageConfig.hs b/compiler/main/PackageConfig.hs
index cda8f7f12c..f16c902a7e 100644
--- a/compiler/main/PackageConfig.hs
+++ b/compiler/main/PackageConfig.hs
@@ -1,4 +1,4 @@
-{-# LANGUAGE CPP, RecordWildCards, MultiParamTypeClasses #-}
+{-# LANGUAGE CPP, RecordWildCards, FlexibleInstances, MultiParamTypeClasses #-}
-- |
-- Package configuration information: essentially the interface to Cabal, with
@@ -11,6 +11,7 @@ module PackageConfig (
-- * UnitId
packageConfigId,
+ expandedPackageConfigId,
-- * The PackageConfig type: information about a package
PackageConfig,
@@ -40,9 +41,11 @@ import Unique
-- which is similar to a subset of the InstalledPackageInfo type from Cabal.
type PackageConfig = InstalledPackageInfo
+ ComponentId
SourcePackageId
PackageName
Module.UnitId
+ Module.UnitId
Module.ModuleName
Module.Module
@@ -50,14 +53,9 @@ type PackageConfig = InstalledPackageInfo
-- feature, but ghc doesn't currently have convenient support for any
-- other compact string types, e.g. plain ByteString or Text.
-newtype ComponentId = ComponentId FastString deriving (Eq, Ord)
newtype SourcePackageId = SourcePackageId FastString deriving (Eq, Ord)
newtype PackageName = PackageName FastString deriving (Eq, Ord)
-instance BinaryStringRep ComponentId where
- fromStringRep = ComponentId . mkFastStringByteString
- toStringRep (ComponentId s) = fastStringToByteString s
-
instance BinaryStringRep SourcePackageId where
fromStringRep = SourcePackageId . mkFastStringByteString
toStringRep (SourcePackageId s) = fastStringToByteString s
@@ -66,18 +64,12 @@ instance BinaryStringRep PackageName where
fromStringRep = PackageName . mkFastStringByteString
toStringRep (PackageName s) = fastStringToByteString s
-instance Uniquable ComponentId where
- getUnique (ComponentId n) = getUnique n
-
instance Uniquable SourcePackageId where
getUnique (SourcePackageId n) = getUnique n
instance Uniquable PackageName where
getUnique (PackageName n) = getUnique n
-instance Outputable ComponentId where
- ppr (ComponentId str) = ftext str
-
instance Outputable SourcePackageId where
ppr (SourcePackageId str) = ftext str
@@ -125,7 +117,6 @@ pprPackageConfig InstalledPackageInfo {..} =
where
field name body = text name <> colon <+> nest 4 body
-
-- -----------------------------------------------------------------------------
-- UnitId (package names, versions and dep hash)
@@ -140,3 +131,9 @@ pprPackageConfig InstalledPackageInfo {..} =
-- | Get the GHC 'UnitId' right out of a Cabalish 'PackageConfig'
packageConfigId :: PackageConfig -> UnitId
packageConfigId = unitId
+
+expandedPackageConfigId :: PackageConfig -> UnitId
+expandedPackageConfigId p =
+ case instantiatedWith p of
+ [] -> packageConfigId p
+ _ -> newUnitId (unitIdComponentId (packageConfigId p)) (instantiatedWith p)