summaryrefslogtreecommitdiff
path: root/compiler/GHC/Unit
diff options
context:
space:
mode:
authorSylvain Henry <sylvain@haskus.fr>2020-03-27 10:49:16 +0100
committerMarge Bot <ben+marge-bot@smart-cactus.org>2020-04-30 01:56:56 -0400
commit10a2ba90aa6a788677104cc43318c66f46e2e2b0 (patch)
tree86f1cadd79243ef67a7f150c5f074e5aa2115ccf /compiler/GHC/Unit
parent2cfc4ab9710c873a55e9a44aac9dacb06ecce36f (diff)
downloadhaskell-10a2ba90aa6a788677104cc43318c66f46e2e2b0.tar.gz
Refactor UnitInfo
* Rename InstalledPackageInfo into GenericUnitInfo The name InstalledPackageInfo is only kept for alleged backward compatibility reason in Cabal. ghc-boot has its own stripped down copy of this datatype but it doesn't need to keep the name. Internally we already use type aliases (UnitInfo in GHC, PackageCacheFormat in ghc-pkg). * Rename UnitInfo fields: add "unit" prefix and fix misleading names * Add comments on every UnitInfo field * Rename SourcePackageId into PackageId "Package" already indicates that it's a "source package". Installed package components are called units. Update Haddock submodule
Diffstat (limited to 'compiler/GHC/Unit')
-rw-r--r--compiler/GHC/Unit/Info.hs94
1 files changed, 47 insertions, 47 deletions
diff --git a/compiler/GHC/Unit/Info.hs b/compiler/GHC/Unit/Info.hs
index 7248d84620..80029dcaa5 100644
--- a/compiler/GHC/Unit/Info.hs
+++ b/compiler/GHC/Unit/Info.hs
@@ -17,14 +17,14 @@ module GHC.Unit.Info (
-- * The UnitInfo type: information about a unit
UnitInfo,
- InstalledPackageInfo(..),
+ GenericUnitInfo(..),
ComponentId(..),
- SourcePackageId(..),
+ PackageId(..),
PackageName(..),
Version(..),
defaultUnitInfo,
- sourcePackageIdString,
- packageNameString,
+ unitPackageNameString,
+ unitPackageIdString,
pprUnitInfo,
) where
@@ -41,12 +41,12 @@ import GHC.Types.Module as Module
import GHC.Types.Unique
-- -----------------------------------------------------------------------------
--- Our UnitInfo type is the InstalledPackageInfo from ghc-boot,
+-- Our UnitInfo type is the GenericUnitInfo from ghc-boot,
-- which is similar to a subset of the InstalledPackageInfo type from Cabal.
-type UnitInfo = InstalledPackageInfo
+type UnitInfo = GenericUnitInfo
ComponentId
- SourcePackageId
+ PackageId
PackageName
Module.InstalledUnitId
Module.UnitId
@@ -57,70 +57,70 @@ type UnitInfo = InstalledPackageInfo
-- feature, but ghc doesn't currently have convenient support for any
-- other compact string types, e.g. plain ByteString or Text.
-newtype SourcePackageId = SourcePackageId FastString deriving (Eq, Ord)
+newtype PackageId = PackageId FastString deriving (Eq, Ord)
newtype PackageName = PackageName
{ unPackageName :: FastString
}
deriving (Eq, Ord)
-instance BinaryStringRep SourcePackageId where
- fromStringRep = SourcePackageId . mkFastStringByteString
- toStringRep (SourcePackageId s) = bytesFS s
+instance BinaryStringRep PackageId where
+ fromStringRep = PackageId . mkFastStringByteString
+ toStringRep (PackageId s) = bytesFS s
instance BinaryStringRep PackageName where
fromStringRep = PackageName . mkFastStringByteString
toStringRep (PackageName s) = bytesFS s
-instance Uniquable SourcePackageId where
- getUnique (SourcePackageId n) = getUnique n
+instance Uniquable PackageId where
+ getUnique (PackageId n) = getUnique n
instance Uniquable PackageName where
getUnique (PackageName n) = getUnique n
-instance Outputable SourcePackageId where
- ppr (SourcePackageId str) = ftext str
+instance Outputable PackageId where
+ ppr (PackageId str) = ftext str
instance Outputable PackageName where
ppr (PackageName str) = ftext str
defaultUnitInfo :: UnitInfo
-defaultUnitInfo = emptyInstalledPackageInfo
+defaultUnitInfo = emptyGenericUnitInfo
-sourcePackageIdString :: UnitInfo -> String
-sourcePackageIdString pkg = unpackFS str
+unitPackageIdString :: UnitInfo -> String
+unitPackageIdString pkg = unpackFS str
where
- SourcePackageId str = sourcePackageId pkg
+ PackageId str = unitPackageId pkg
-packageNameString :: UnitInfo -> String
-packageNameString pkg = unpackFS str
+unitPackageNameString :: UnitInfo -> String
+unitPackageNameString pkg = unpackFS str
where
- PackageName str = packageName pkg
+ PackageName str = unitPackageName pkg
pprUnitInfo :: UnitInfo -> SDoc
-pprUnitInfo InstalledPackageInfo {..} =
+pprUnitInfo GenericUnitInfo {..} =
vcat [
- field "name" (ppr packageName),
- field "version" (text (showVersion packageVersion)),
+ field "name" (ppr unitPackageName),
+ field "version" (text (showVersion unitPackageVersion)),
field "id" (ppr unitId),
- field "exposed" (ppr exposed),
- field "exposed-modules" (ppr exposedModules),
- field "hidden-modules" (fsep (map ppr hiddenModules)),
- field "trusted" (ppr trusted),
- field "import-dirs" (fsep (map text importDirs)),
- field "library-dirs" (fsep (map text libraryDirs)),
- field "dynamic-library-dirs" (fsep (map text libraryDynDirs)),
- field "hs-libraries" (fsep (map text hsLibraries)),
- field "extra-libraries" (fsep (map text extraLibraries)),
- field "extra-ghci-libraries" (fsep (map text extraGHCiLibraries)),
- field "include-dirs" (fsep (map text includeDirs)),
- field "includes" (fsep (map text includes)),
- field "depends" (fsep (map ppr depends)),
- field "cc-options" (fsep (map text ccOptions)),
- field "ld-options" (fsep (map text ldOptions)),
- field "framework-dirs" (fsep (map text frameworkDirs)),
- field "frameworks" (fsep (map text frameworks)),
- field "haddock-interfaces" (fsep (map text haddockInterfaces)),
- field "haddock-html" (fsep (map text haddockHTMLs))
+ field "exposed" (ppr unitIsExposed),
+ field "exposed-modules" (ppr unitExposedModules),
+ field "hidden-modules" (fsep (map ppr unitHiddenModules)),
+ field "trusted" (ppr unitIsTrusted),
+ field "import-dirs" (fsep (map text unitImportDirs)),
+ field "library-dirs" (fsep (map text unitLibraryDirs)),
+ field "dynamic-library-dirs" (fsep (map text unitLibraryDynDirs)),
+ field "hs-libraries" (fsep (map text unitLibraries)),
+ field "extra-libraries" (fsep (map text unitExtDepLibsSys)),
+ field "extra-ghci-libraries" (fsep (map text unitExtDepLibsGhc)),
+ field "include-dirs" (fsep (map text unitIncludeDirs)),
+ field "includes" (fsep (map text unitIncludes)),
+ field "depends" (fsep (map ppr unitDepends)),
+ field "cc-options" (fsep (map text unitCcOptions)),
+ field "ld-options" (fsep (map text unitLinkerOptions)),
+ field "framework-dirs" (fsep (map text unitExtDepFrameworkDirs)),
+ field "frameworks" (fsep (map text unitExtDepFrameworks)),
+ field "haddock-interfaces" (fsep (map text unitHaddockInterfaces)),
+ field "haddock-html" (fsep (map text unitHaddockHTMLs))
]
where
field name body = text name <> colon <+> nest 4 body
@@ -142,13 +142,13 @@ installedUnitInfoId = unitId
packageConfigId :: UnitInfo -> UnitId
packageConfigId p =
- if indefinite p
- then newUnitId (componentId p) (instantiatedWith p)
+ if unitIsIndefinite p
+ then newUnitId (unitInstanceOf p) (unitInstantiations p)
else DefiniteUnitId (DefUnitId (unitId p))
expandedUnitInfoId :: UnitInfo -> UnitId
expandedUnitInfoId p =
- newUnitId (componentId p) (instantiatedWith p)
+ newUnitId (unitInstanceOf p) (unitInstantiations p)
definiteUnitInfoId :: UnitInfo -> Maybe DefUnitId
definiteUnitInfoId p =