1 {-# LANGUAGE DeriveDataTypeable #-}
2 {-# LANGUAGE DeriveGeneric #-}
3 {-# LANGUAGE OverloadedStrings #-}
4 {-# LANGUAGE TypeFamilies #-}
6 module Distribution
.Types
.InstalledPackageInfo
7 ( InstalledPackageInfo
(..)
8 , emptyInstalledPackageInfo
15 import Distribution
.Compat
.Prelude
18 import Distribution
.Backpack
19 import Distribution
.Compat
.Graph
(IsNode
(..))
20 import Distribution
.License
21 import Distribution
.ModuleName
22 import Distribution
.Package
hiding (installedUnitId
)
23 import Distribution
.Types
.AbiDependency
24 import Distribution
.Types
.ExposedModule
25 import Distribution
.Types
.LibraryName
26 import Distribution
.Types
.LibraryVisibility
27 import Distribution
.Types
.MungedPackageId
28 import Distribution
.Types
.MungedPackageName
29 import Distribution
.Utils
.ShortText
(ShortText
)
30 import Distribution
.Version
(nullVersion
)
32 import qualified Distribution
.Package
as Package
33 import qualified Distribution
.SPDX
as SPDX
35 -- -----------------------------------------------------------------------------
36 -- The InstalledPackageInfo type
38 -- For BC reasons, we continue to name this record an InstalledPackageInfo;
39 -- but it would more accurately be called an InstalledUnitInfo with Backpack
40 data InstalledPackageInfo
= InstalledPackageInfo
41 { -- these parts (sourcePackageId, installedUnitId) are
42 -- exactly the same as PackageDescription
43 sourcePackageId
:: PackageId
44 , sourceLibName
:: LibraryName
45 , installedComponentId_
:: ComponentId
46 , libVisibility
:: LibraryVisibility
47 , installedUnitId
:: UnitId
48 , -- INVARIANT: if this package is definite, OpenModule's
49 -- OpenUnitId directly records UnitId. If it is
50 -- indefinite, OpenModule is always an OpenModuleVar
51 -- with the same ModuleName as the key.
52 instantiatedWith
:: [(ModuleName
, OpenModule
)]
53 , compatPackageKey
:: String
54 , license
:: Either SPDX
.License License
55 , copyright
:: !ShortText
56 , maintainer
:: !ShortText
57 , author
:: !ShortText
58 , stability
:: !ShortText
59 , homepage
:: !ShortText
60 , pkgUrl
:: !ShortText
61 , synopsis
:: !ShortText
62 , description
:: !ShortText
63 , category
:: !ShortText
64 , -- these parts are required by an installed package only:
68 , -- INVARIANT: if the package is definite, OpenModule's
69 -- OpenUnitId directly records UnitId.
70 exposedModules
:: [ExposedModule
]
71 , hiddenModules
:: [ModuleName
]
73 , importDirs
:: [FilePath]
74 , libraryDirs
:: [FilePath]
75 , libraryDirsStatic
:: [FilePath]
76 , libraryDynDirs
:: [FilePath]
77 -- ^ overrides 'libraryDirs'
79 , hsLibraries
:: [String]
80 , extraLibraries
:: [String]
81 , extraLibrariesStatic
:: [String]
82 , extraGHCiLibraries
:: [String] -- overrides extraLibraries for GHCi
83 , includeDirs
:: [FilePath]
84 , includes
:: [String]
85 , -- INVARIANT: if the package is definite, UnitId is NOT
86 -- a ComponentId of an indefinite package
88 , abiDepends
:: [AbiDependency
]
89 , ccOptions
:: [String]
90 , cxxOptions
:: [String]
91 , ldOptions
:: [String]
92 , frameworkDirs
:: [FilePath]
93 , frameworks
:: [String]
94 , haddockInterfaces
:: [FilePath]
95 , haddockHTMLs
:: [FilePath]
96 , pkgRoot
:: Maybe FilePath
98 deriving (Eq
, Generic
, Typeable
, Read, Show)
100 instance Binary InstalledPackageInfo
101 instance Structured InstalledPackageInfo
103 instance NFData InstalledPackageInfo
where rnf
= genericRnf
105 instance Package
.HasMungedPackageId InstalledPackageInfo
where
106 mungedId
= mungedPackageId
108 instance Package
.Package InstalledPackageInfo
where
109 packageId
= sourcePackageId
111 instance Package
.HasUnitId InstalledPackageInfo
where
112 installedUnitId
= installedUnitId
114 instance Package
.PackageInstalled InstalledPackageInfo
where
115 installedDepends
= depends
117 instance IsNode InstalledPackageInfo
where
118 type Key InstalledPackageInfo
= UnitId
119 nodeKey
= installedUnitId
120 nodeNeighbors
= depends
122 mungedPackageId
:: InstalledPackageInfo
-> MungedPackageId
123 mungedPackageId ipi
=
124 MungedPackageId
(mungedPackageName ipi
) (packageVersion ipi
)
126 -- | Returns the munged package name, which we write into @name@ for
127 -- compatibility with old versions of GHC.
128 mungedPackageName
:: InstalledPackageInfo
-> MungedPackageName
129 mungedPackageName ipi
= MungedPackageName
(packageName ipi
) (sourceLibName ipi
)
131 emptyInstalledPackageInfo
:: InstalledPackageInfo
132 emptyInstalledPackageInfo
=
134 { sourcePackageId
= PackageIdentifier
(mkPackageName
"") nullVersion
135 , sourceLibName
= LMainLibName
136 , installedComponentId_
= mkComponentId
""
137 , installedUnitId
= mkUnitId
""
138 , instantiatedWith
= []
139 , compatPackageKey
= ""
140 , license
= Left SPDX
.NONE
150 , abiHash
= mkAbiHash
""
153 , exposedModules
= []
158 , libraryDirsStatic
= []
159 , libraryDynDirs
= []
162 , extraLibraries
= []
163 , extraLibrariesStatic
= []
164 , extraGHCiLibraries
= []
174 , haddockInterfaces
= []
177 , libVisibility
= LibraryVisibilityPrivate