1 {-# LANGUAGE DeriveDataTypeable #-}
2 {-# LANGUAGE DeriveGeneric #-}
3 {-# LANGUAGE TypeFamilies #-}
5 module Distribution
.Types
.ComponentLocalBuildInfo
6 ( ComponentLocalBuildInfo
(..)
7 , componentIsIndefinite
8 , maybeComponentInstantiatedWith
11 import Distribution
.Compat
.Prelude
12 import Distribution
.ModuleName
15 import Distribution
.Backpack
16 import Distribution
.Compat
.Graph
17 import Distribution
.Types
.ComponentId
18 import Distribution
.Types
.ComponentName
19 import Distribution
.Types
.ModuleRenaming
20 import Distribution
.Types
.MungedPackageId
21 import Distribution
.Types
.MungedPackageName
22 import Distribution
.Types
.UnitId
24 import qualified Distribution
.InstalledPackageInfo
as Installed
26 -- | The first five fields are common across all algebraic variants.
27 data ComponentLocalBuildInfo
28 = LibComponentLocalBuildInfo
29 { componentLocalName
:: ComponentName
30 -- ^ It would be very convenient to store the literal Library here,
31 -- but if we do that, it will get serialized (via the Binary)
32 -- instance twice. So instead we just provide the ComponentName,
33 -- which can be used to find the Component in the
34 -- PackageDescription. NB: eventually, this will NOT uniquely
35 -- identify the ComponentLocalBuildInfo.
36 , componentComponentId
:: ComponentId
37 -- ^ The computed 'ComponentId' of this component.
38 , componentUnitId
:: UnitId
39 -- ^ The computed 'UnitId' which uniquely identifies this
40 -- component. Might be hashed.
41 , componentIsIndefinite_
:: Bool
42 -- ^ Is this an indefinite component (i.e. has unfilled holes)?
43 , componentInstantiatedWith
:: [(ModuleName
, OpenModule
)]
44 -- ^ How the component was instantiated
45 , componentPackageDeps
:: [(UnitId
, MungedPackageId
)]
46 -- ^ Resolved internal and external package dependencies for this component.
47 -- The 'BuildInfo' specifies a set of build dependencies that must be
48 -- satisfied in terms of version ranges. This field fixes those dependencies
49 -- to the specific versions available on this machine for this compiler.
50 , componentIncludes
:: [(OpenUnitId
, ModuleRenaming
)]
51 -- ^ The set of packages that are brought into scope during
52 -- compilation, including a 'ModuleRenaming' which may used
53 -- to hide or rename modules. This is what gets translated into
54 -- @-package-id@ arguments. This is a modernized version of
55 -- 'componentPackageDeps', which is kept around for BC purposes.
56 , componentExeDeps
:: [UnitId
]
57 , componentInternalDeps
:: [UnitId
]
58 -- ^ The internal dependencies which induce a graph on the
59 -- 'ComponentLocalBuildInfo' of this package. This does NOT
60 -- coincide with 'componentPackageDeps' because it ALSO records
61 -- 'build-tool' dependencies on executables. Maybe one day
62 -- @cabal-install@ will also handle these correctly too!
63 , componentCompatPackageKey
:: String
64 -- ^ Compatibility "package key" that we pass to older versions of GHC.
65 , componentCompatPackageName
:: MungedPackageName
66 -- ^ Compatibility "package name" that we register this component as.
67 , componentExposedModules
:: [Installed
.ExposedModule
]
68 -- ^ A list of exposed modules (either defined in this component,
69 -- or reexported from another component.)
70 , componentIsPublic
:: Bool
71 -- ^ Convenience field, specifying whether or not this is the
72 -- "public library" that has the same name as the package.
74 |
-- TODO: refactor all these duplicates
75 FLibComponentLocalBuildInfo
76 { componentLocalName
:: ComponentName
77 , componentComponentId
:: ComponentId
78 , componentUnitId
:: UnitId
79 , componentPackageDeps
:: [(UnitId
, MungedPackageId
)]
80 , componentIncludes
:: [(OpenUnitId
, ModuleRenaming
)]
81 , componentExeDeps
:: [UnitId
]
82 , componentInternalDeps
:: [UnitId
]
84 | ExeComponentLocalBuildInfo
85 { componentLocalName
:: ComponentName
86 , componentComponentId
:: ComponentId
87 , componentUnitId
:: UnitId
88 , componentPackageDeps
:: [(UnitId
, MungedPackageId
)]
89 , componentIncludes
:: [(OpenUnitId
, ModuleRenaming
)]
90 , componentExeDeps
:: [UnitId
]
91 , componentInternalDeps
:: [UnitId
]
93 | TestComponentLocalBuildInfo
94 { componentLocalName
:: ComponentName
95 , componentComponentId
:: ComponentId
96 , componentUnitId
:: UnitId
97 , componentPackageDeps
:: [(UnitId
, MungedPackageId
)]
98 , componentIncludes
:: [(OpenUnitId
, ModuleRenaming
)]
99 , componentExeDeps
:: [UnitId
]
100 , componentInternalDeps
:: [UnitId
]
102 | BenchComponentLocalBuildInfo
103 { componentLocalName
:: ComponentName
104 , componentComponentId
:: ComponentId
105 , componentUnitId
:: UnitId
106 , componentPackageDeps
:: [(UnitId
, MungedPackageId
)]
107 , componentIncludes
:: [(OpenUnitId
, ModuleRenaming
)]
108 , componentExeDeps
:: [UnitId
]
109 , componentInternalDeps
:: [UnitId
]
111 deriving (Generic
, Read, Show, Typeable
)
113 instance Binary ComponentLocalBuildInfo
114 instance Structured ComponentLocalBuildInfo
116 instance IsNode ComponentLocalBuildInfo
where
117 type Key ComponentLocalBuildInfo
= UnitId
118 nodeKey
= componentUnitId
119 nodeNeighbors
= componentInternalDeps
121 componentIsIndefinite
:: ComponentLocalBuildInfo
-> Bool
122 componentIsIndefinite LibComponentLocalBuildInfo
{componentIsIndefinite_
= b
} = b
123 componentIsIndefinite _
= False
125 maybeComponentInstantiatedWith
:: ComponentLocalBuildInfo
-> Maybe [(ModuleName
, OpenModule
)]
126 maybeComponentInstantiatedWith
127 LibComponentLocalBuildInfo
{componentInstantiatedWith
= insts
} = Just insts
128 maybeComponentInstantiatedWith _
= Nothing