module GHC.Unit.Env
( UnitEnv (..)
, preloadUnitsInfo
, preloadUnitsInfo'
)
where
import GHC.Prelude
import GHC.Unit.State
import GHC.Unit.Home
import GHC.Unit.Types
import GHC.Platform
import GHC.Settings
import GHC.Data.Maybe
data UnitEnv = UnitEnv
{ UnitEnv -> UnitState
ue_units :: !UnitState
, UnitEnv -> HomeUnit
ue_home_unit :: !HomeUnit
, UnitEnv -> Platform
ue_platform :: !Platform
, UnitEnv -> GhcNameVersion
ue_namever :: !GhcNameVersion
}
preloadUnitsInfo' :: UnitEnv -> [UnitId] -> MaybeErr UnitErr [UnitInfo]
preloadUnitsInfo' :: UnitEnv -> [UnitId] -> MaybeErr UnitErr [UnitInfo]
preloadUnitsInfo' UnitEnv
unit_env [UnitId]
ids0 = MaybeErr UnitErr [UnitInfo]
all_infos
where
home_unit :: HomeUnit
home_unit = UnitEnv -> HomeUnit
ue_home_unit UnitEnv
unit_env
unit_state :: UnitState
unit_state = UnitEnv -> UnitState
ue_units UnitEnv
unit_env
ids :: [UnitId]
ids = [UnitId]
ids0 forall a. [a] -> [a] -> [a]
++ [UnitId]
inst_ids
inst_ids :: [UnitId]
inst_ids
| forall u. GenHomeUnit u -> Bool
isHomeUnitIndefinite HomeUnit
home_unit = []
| Bool
otherwise = forall a b. (a -> b) -> [a] -> [b]
map (Unit -> UnitId
toUnitId forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall unit. GenModule unit -> unit
moduleUnit forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a b. (a, b) -> b
snd) (forall u. GenHomeUnit u -> GenInstantiations u
homeUnitInstantiations HomeUnit
home_unit)
pkg_map :: UnitInfoMap
pkg_map = UnitState -> UnitInfoMap
unitInfoMap UnitState
unit_state
preload :: [UnitId]
preload = UnitState -> [UnitId]
preloadUnits UnitState
unit_state
all_pkgs :: MaybeErr UnitErr [UnitId]
all_pkgs = UnitInfoMap
-> [UnitId]
-> [(UnitId, Maybe UnitId)]
-> MaybeErr UnitErr [UnitId]
closeUnitDeps' UnitInfoMap
pkg_map [UnitId]
preload ([UnitId]
ids forall a b. [a] -> [b] -> [(a, b)]
`zip` forall a. a -> [a]
repeat forall a. Maybe a
Nothing)
all_infos :: MaybeErr UnitErr [UnitInfo]
all_infos = forall a b. (a -> b) -> [a] -> [b]
map (HasDebugCallStack => UnitState -> UnitId -> UnitInfo
unsafeLookupUnitId UnitState
unit_state) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> MaybeErr UnitErr [UnitId]
all_pkgs
preloadUnitsInfo :: UnitEnv -> MaybeErr UnitErr [UnitInfo]
preloadUnitsInfo :: UnitEnv -> MaybeErr UnitErr [UnitInfo]
preloadUnitsInfo UnitEnv
unit_env = UnitEnv -> [UnitId] -> MaybeErr UnitErr [UnitInfo]
preloadUnitsInfo' UnitEnv
unit_env []