module GHC.Unit.Module.Deps
( Dependencies
, mkDependencies
, noDependencies
, dep_direct_mods
, dep_direct_pkgs
, dep_sig_mods
, dep_trusted_pkgs
, dep_orphs
, dep_plugin_pkgs
, dep_finsts
, dep_boot_mods
, dep_orphs_update
, dep_finsts_update
, pprDeps
, Usage (..)
, ImportAvails (..)
)
where
import GHC.Prelude
import GHC.Types.SafeHaskell
import GHC.Types.Name
import GHC.Unit.Module.Imported
import GHC.Unit.Module
import GHC.Unit.Home
import GHC.Unit.State
import GHC.Utils.Fingerprint
import GHC.Utils.Binary
import GHC.Utils.Outputable
import Data.List (sortBy, sort, partition)
import Data.Set (Set)
import qualified Data.Set as Set
import Data.Bifunctor
data Dependencies = Deps
{ Dependencies -> Set (UnitId, GenWithIsBoot ModuleName)
dep_direct_mods :: Set (UnitId, ModuleNameWithIsBoot)
, Dependencies -> Set UnitId
dep_direct_pkgs :: Set UnitId
, Dependencies -> Set UnitId
dep_plugin_pkgs :: Set UnitId
, Dependencies -> [ModuleName]
dep_sig_mods :: ![ModuleName]
, Dependencies -> Set UnitId
dep_trusted_pkgs :: Set UnitId
, Dependencies -> Set (UnitId, GenWithIsBoot ModuleName)
dep_boot_mods :: Set (UnitId, ModuleNameWithIsBoot)
, Dependencies -> [Module]
dep_orphs :: [Module]
, Dependencies -> [Module]
dep_finsts :: [Module]
}
deriving( Dependencies -> Dependencies -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Dependencies -> Dependencies -> Bool
$c/= :: Dependencies -> Dependencies -> Bool
== :: Dependencies -> Dependencies -> Bool
$c== :: Dependencies -> Dependencies -> Bool
Eq )
mkDependencies :: HomeUnit -> Module -> ImportAvails -> [Module] -> Dependencies
mkDependencies :: HomeUnit -> Module -> ImportAvails -> [Module] -> Dependencies
mkDependencies HomeUnit
home_unit Module
mod ImportAvails
imports [Module]
plugin_mods =
let ([Module]
home_plugins, [Module]
external_plugins) = forall a. (a -> Bool) -> [a] -> ([a], [a])
partition (HomeUnit -> GenUnit UnitId -> Bool
isHomeUnit HomeUnit
home_unit forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall unit. GenModule unit -> unit
moduleUnit) [Module]
plugin_mods
plugin_units :: Set UnitId
plugin_units = forall a. Ord a => [a] -> Set a
Set.fromList (forall a b. (a -> b) -> [a] -> [b]
map (GenUnit UnitId -> UnitId
toUnitId forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall unit. GenModule unit -> unit
moduleUnit) [Module]
external_plugins)
all_direct_mods :: InstalledModuleEnv (GenWithIsBoot ModuleName)
all_direct_mods = forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr (\InstalledModule
mn InstalledModuleEnv (GenWithIsBoot ModuleName)
m -> forall a.
InstalledModuleEnv a
-> InstalledModule -> a -> InstalledModuleEnv a
extendInstalledModuleEnv InstalledModuleEnv (GenWithIsBoot ModuleName)
m InstalledModule
mn (forall mod. mod -> IsBootInterface -> GenWithIsBoot mod
GWIB (forall unit. GenModule unit -> ModuleName
moduleName InstalledModule
mn) IsBootInterface
NotBoot))
(ImportAvails -> InstalledModuleEnv (GenWithIsBoot ModuleName)
imp_direct_dep_mods ImportAvails
imports)
(forall a b. (a -> b) -> [a] -> [b]
map (forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap GenUnit UnitId -> UnitId
toUnitId) [Module]
home_plugins)
modDepsElts :: InstalledModuleEnv (GenWithIsBoot ModuleName)
-> Set (InstalledModule, GenWithIsBoot ModuleName)
modDepsElts = forall a. Ord a => [a] -> Set a
Set.fromList forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. InstalledModuleEnv a -> [(InstalledModule, a)]
installedModuleEnvElts
direct_mods :: Set (UnitId, GenWithIsBoot ModuleName)
direct_mods = forall (p :: * -> * -> *) a b c.
Bifunctor p =>
(a -> b) -> p a c -> p b c
first forall unit. GenModule unit -> unit
moduleUnit forall b a. Ord b => (a -> b) -> Set a -> Set b
`Set.map` InstalledModuleEnv (GenWithIsBoot ModuleName)
-> Set (InstalledModule, GenWithIsBoot ModuleName)
modDepsElts (forall a.
InstalledModuleEnv a -> InstalledModule -> InstalledModuleEnv a
delInstalledModuleEnv InstalledModuleEnv (GenWithIsBoot ModuleName)
all_direct_mods (GenUnit UnitId -> UnitId
toUnitId forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Module
mod))
dep_orphs :: [Module]
dep_orphs = forall a. (a -> Bool) -> [a] -> [a]
filter (forall a. Eq a => a -> a -> Bool
/= Module
mod) (ImportAvails -> [Module]
imp_orphs ImportAvails
imports)
direct_pkgs :: Set UnitId
direct_pkgs = ImportAvails -> Set UnitId
imp_dep_direct_pkgs ImportAvails
imports
trust_pkgs :: Set UnitId
trust_pkgs = ImportAvails -> Set UnitId
imp_trust_pkgs ImportAvails
imports
source_mods :: Set (UnitId, GenWithIsBoot ModuleName)
source_mods = forall (p :: * -> * -> *) a b c.
Bifunctor p =>
(a -> b) -> p a c -> p b c
first forall unit. GenModule unit -> unit
moduleUnit forall b a. Ord b => (a -> b) -> Set a -> Set b
`Set.map` InstalledModuleEnv (GenWithIsBoot ModuleName)
-> Set (InstalledModule, GenWithIsBoot ModuleName)
modDepsElts (ImportAvails -> InstalledModuleEnv (GenWithIsBoot ModuleName)
imp_boot_mods ImportAvails
imports)
sig_mods :: [ModuleName]
sig_mods = forall a. (a -> Bool) -> [a] -> [a]
filter (forall a. Eq a => a -> a -> Bool
/= (forall unit. GenModule unit -> ModuleName
moduleName Module
mod)) forall a b. (a -> b) -> a -> b
$ ImportAvails -> [ModuleName]
imp_sig_mods ImportAvails
imports
in Deps { dep_direct_mods :: Set (UnitId, GenWithIsBoot ModuleName)
dep_direct_mods = Set (UnitId, GenWithIsBoot ModuleName)
direct_mods
, dep_direct_pkgs :: Set UnitId
dep_direct_pkgs = Set UnitId
direct_pkgs
, dep_plugin_pkgs :: Set UnitId
dep_plugin_pkgs = Set UnitId
plugin_units
, dep_sig_mods :: [ModuleName]
dep_sig_mods = forall a. Ord a => [a] -> [a]
sort [ModuleName]
sig_mods
, dep_trusted_pkgs :: Set UnitId
dep_trusted_pkgs = Set UnitId
trust_pkgs
, dep_boot_mods :: Set (UnitId, GenWithIsBoot ModuleName)
dep_boot_mods = Set (UnitId, GenWithIsBoot ModuleName)
source_mods
, dep_orphs :: [Module]
dep_orphs = forall a. (a -> a -> Ordering) -> [a] -> [a]
sortBy Module -> Module -> Ordering
stableModuleCmp [Module]
dep_orphs
, dep_finsts :: [Module]
dep_finsts = forall a. (a -> a -> Ordering) -> [a] -> [a]
sortBy Module -> Module -> Ordering
stableModuleCmp (ImportAvails -> [Module]
imp_finsts ImportAvails
imports)
}
dep_orphs_update :: Monad m => Dependencies -> ([Module] -> m [Module]) -> m Dependencies
dep_orphs_update :: forall (m :: * -> *).
Monad m =>
Dependencies -> ([Module] -> m [Module]) -> m Dependencies
dep_orphs_update Dependencies
deps [Module] -> m [Module]
f = do
[Module]
r <- [Module] -> m [Module]
f (Dependencies -> [Module]
dep_orphs Dependencies
deps)
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Dependencies
deps { dep_orphs :: [Module]
dep_orphs = forall a. (a -> a -> Ordering) -> [a] -> [a]
sortBy Module -> Module -> Ordering
stableModuleCmp [Module]
r })
dep_finsts_update :: Monad m => Dependencies -> ([Module] -> m [Module]) -> m Dependencies
dep_finsts_update :: forall (m :: * -> *).
Monad m =>
Dependencies -> ([Module] -> m [Module]) -> m Dependencies
dep_finsts_update Dependencies
deps [Module] -> m [Module]
f = do
[Module]
r <- [Module] -> m [Module]
f (Dependencies -> [Module]
dep_finsts Dependencies
deps)
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Dependencies
deps { dep_finsts :: [Module]
dep_finsts = forall a. (a -> a -> Ordering) -> [a] -> [a]
sortBy Module -> Module -> Ordering
stableModuleCmp [Module]
r })
instance Binary Dependencies where
put_ :: BinHandle -> Dependencies -> IO ()
put_ BinHandle
bh Dependencies
deps = do forall a. Binary a => BinHandle -> a -> IO ()
put_ BinHandle
bh (Dependencies -> Set (UnitId, GenWithIsBoot ModuleName)
dep_direct_mods Dependencies
deps)
forall a. Binary a => BinHandle -> a -> IO ()
put_ BinHandle
bh (Dependencies -> Set UnitId
dep_direct_pkgs Dependencies
deps)
forall a. Binary a => BinHandle -> a -> IO ()
put_ BinHandle
bh (Dependencies -> Set UnitId
dep_plugin_pkgs Dependencies
deps)
forall a. Binary a => BinHandle -> a -> IO ()
put_ BinHandle
bh (Dependencies -> Set UnitId
dep_trusted_pkgs Dependencies
deps)
forall a. Binary a => BinHandle -> a -> IO ()
put_ BinHandle
bh (Dependencies -> [ModuleName]
dep_sig_mods Dependencies
deps)
forall a. Binary a => BinHandle -> a -> IO ()
put_ BinHandle
bh (Dependencies -> Set (UnitId, GenWithIsBoot ModuleName)
dep_boot_mods Dependencies
deps)
forall a. Binary a => BinHandle -> a -> IO ()
put_ BinHandle
bh (Dependencies -> [Module]
dep_orphs Dependencies
deps)
forall a. Binary a => BinHandle -> a -> IO ()
put_ BinHandle
bh (Dependencies -> [Module]
dep_finsts Dependencies
deps)
get :: BinHandle -> IO Dependencies
get BinHandle
bh = do Set (UnitId, GenWithIsBoot ModuleName)
dms <- forall a. Binary a => BinHandle -> IO a
get BinHandle
bh
Set UnitId
dps <- forall a. Binary a => BinHandle -> IO a
get BinHandle
bh
Set UnitId
plugin_pkgs <- forall a. Binary a => BinHandle -> IO a
get BinHandle
bh
Set UnitId
tps <- forall a. Binary a => BinHandle -> IO a
get BinHandle
bh
[ModuleName]
hsigms <- forall a. Binary a => BinHandle -> IO a
get BinHandle
bh
Set (UnitId, GenWithIsBoot ModuleName)
sms <- forall a. Binary a => BinHandle -> IO a
get BinHandle
bh
[Module]
os <- forall a. Binary a => BinHandle -> IO a
get BinHandle
bh
[Module]
fis <- forall a. Binary a => BinHandle -> IO a
get BinHandle
bh
forall (m :: * -> *) a. Monad m => a -> m a
return (Deps { dep_direct_mods :: Set (UnitId, GenWithIsBoot ModuleName)
dep_direct_mods = Set (UnitId, GenWithIsBoot ModuleName)
dms
, dep_direct_pkgs :: Set UnitId
dep_direct_pkgs = Set UnitId
dps
, dep_plugin_pkgs :: Set UnitId
dep_plugin_pkgs = Set UnitId
plugin_pkgs
, dep_sig_mods :: [ModuleName]
dep_sig_mods = [ModuleName]
hsigms
, dep_boot_mods :: Set (UnitId, GenWithIsBoot ModuleName)
dep_boot_mods = Set (UnitId, GenWithIsBoot ModuleName)
sms
, dep_trusted_pkgs :: Set UnitId
dep_trusted_pkgs = Set UnitId
tps
, dep_orphs :: [Module]
dep_orphs = [Module]
os,
dep_finsts :: [Module]
dep_finsts = [Module]
fis })
noDependencies :: Dependencies
noDependencies :: Dependencies
noDependencies = Deps
{ dep_direct_mods :: Set (UnitId, GenWithIsBoot ModuleName)
dep_direct_mods = forall a. Set a
Set.empty
, dep_direct_pkgs :: Set UnitId
dep_direct_pkgs = forall a. Set a
Set.empty
, dep_plugin_pkgs :: Set UnitId
dep_plugin_pkgs = forall a. Set a
Set.empty
, dep_sig_mods :: [ModuleName]
dep_sig_mods = []
, dep_boot_mods :: Set (UnitId, GenWithIsBoot ModuleName)
dep_boot_mods = forall a. Set a
Set.empty
, dep_trusted_pkgs :: Set UnitId
dep_trusted_pkgs = forall a. Set a
Set.empty
, dep_orphs :: [Module]
dep_orphs = []
, dep_finsts :: [Module]
dep_finsts = []
}
pprDeps :: UnitState -> Dependencies -> SDoc
pprDeps :: UnitState -> Dependencies -> SDoc
pprDeps UnitState
unit_state (Deps { dep_direct_mods :: Dependencies -> Set (UnitId, GenWithIsBoot ModuleName)
dep_direct_mods = Set (UnitId, GenWithIsBoot ModuleName)
dmods
, dep_boot_mods :: Dependencies -> Set (UnitId, GenWithIsBoot ModuleName)
dep_boot_mods = Set (UnitId, GenWithIsBoot ModuleName)
bmods
, dep_plugin_pkgs :: Dependencies -> Set UnitId
dep_plugin_pkgs = Set UnitId
plgns
, dep_orphs :: Dependencies -> [Module]
dep_orphs = [Module]
orphs
, dep_direct_pkgs :: Dependencies -> Set UnitId
dep_direct_pkgs = Set UnitId
pkgs
, dep_trusted_pkgs :: Dependencies -> Set UnitId
dep_trusted_pkgs = Set UnitId
tps
, dep_finsts :: Dependencies -> [Module]
dep_finsts = [Module]
finsts
})
= UnitState -> SDoc -> SDoc
pprWithUnitState UnitState
unit_state forall a b. (a -> b) -> a -> b
$
forall doc. IsDoc doc => [doc] -> doc
vcat [forall doc. IsLine doc => String -> doc
text String
"direct module dependencies:" forall doc. IsLine doc => doc -> doc -> doc
<+> forall a. Outputable a => (a -> SDoc) -> Set a -> SDoc
ppr_set forall {a} {a}.
(Outputable a, Outputable a) =>
(a, GenWithIsBoot a) -> SDoc
ppr_mod Set (UnitId, GenWithIsBoot ModuleName)
dmods,
forall doc. IsLine doc => String -> doc
text String
"boot module dependencies:" forall doc. IsLine doc => doc -> doc -> doc
<+> forall a. Outputable a => (a -> SDoc) -> Set a -> SDoc
ppr_set forall a. Outputable a => a -> SDoc
ppr Set (UnitId, GenWithIsBoot ModuleName)
bmods,
forall doc. IsLine doc => String -> doc
text String
"direct package dependencies:" forall doc. IsLine doc => doc -> doc -> doc
<+> forall a. Outputable a => (a -> SDoc) -> Set a -> SDoc
ppr_set forall a. Outputable a => a -> SDoc
ppr Set UnitId
pkgs,
forall doc. IsLine doc => String -> doc
text String
"plugin package dependencies:" forall doc. IsLine doc => doc -> doc -> doc
<+> forall a. Outputable a => (a -> SDoc) -> Set a -> SDoc
ppr_set forall a. Outputable a => a -> SDoc
ppr Set UnitId
plgns,
if forall (t :: * -> *) a. Foldable t => t a -> Bool
null Set UnitId
tps
then forall doc. IsOutput doc => doc
empty
else forall doc. IsLine doc => String -> doc
text String
"trusted package dependencies:" forall doc. IsLine doc => doc -> doc -> doc
<+> forall a. Outputable a => (a -> SDoc) -> Set a -> SDoc
ppr_set forall a. Outputable a => a -> SDoc
ppr Set UnitId
tps,
forall doc. IsLine doc => String -> doc
text String
"orphans:" forall doc. IsLine doc => doc -> doc -> doc
<+> forall doc. IsLine doc => [doc] -> doc
fsep (forall a b. (a -> b) -> [a] -> [b]
map forall a. Outputable a => a -> SDoc
ppr [Module]
orphs),
forall doc. IsLine doc => String -> doc
text String
"family instance modules:" forall doc. IsLine doc => doc -> doc -> doc
<+> forall doc. IsLine doc => [doc] -> doc
fsep (forall a b. (a -> b) -> [a] -> [b]
map forall a. Outputable a => a -> SDoc
ppr [Module]
finsts)
]
where
ppr_mod :: (a, GenWithIsBoot a) -> SDoc
ppr_mod (a
uid, (GWIB a
mod IsBootInterface
IsBoot)) = forall a. Outputable a => a -> SDoc
ppr a
uid forall doc. IsLine doc => doc -> doc -> doc
<> forall doc. IsLine doc => doc
colon forall doc. IsLine doc => doc -> doc -> doc
<> forall a. Outputable a => a -> SDoc
ppr a
mod forall doc. IsLine doc => doc -> doc -> doc
<+> forall doc. IsLine doc => String -> doc
text String
"[boot]"
ppr_mod (a
uid, (GWIB a
mod IsBootInterface
NotBoot)) = forall a. Outputable a => a -> SDoc
ppr a
uid forall doc. IsLine doc => doc -> doc -> doc
<> forall doc. IsLine doc => doc
colon forall doc. IsLine doc => doc -> doc -> doc
<> forall a. Outputable a => a -> SDoc
ppr a
mod
ppr_set :: Outputable a => (a -> SDoc) -> Set a -> SDoc
ppr_set :: forall a. Outputable a => (a -> SDoc) -> Set a -> SDoc
ppr_set a -> SDoc
w = forall doc. IsLine doc => [doc] -> doc
fsep forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> SDoc
w forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Set a -> [a]
Set.toAscList
data Usage
= UsagePackageModule {
Usage -> Module
usg_mod :: Module,
Usage -> Fingerprint
usg_mod_hash :: Fingerprint,
Usage -> Bool
usg_safe :: IsSafeImport
}
| UsageHomeModule {
Usage -> ModuleName
usg_mod_name :: ModuleName,
Usage -> UnitId
usg_unit_id :: UnitId,
usg_mod_hash :: Fingerprint,
Usage -> [(OccName, Fingerprint)]
usg_entities :: [(OccName,Fingerprint)],
Usage -> Maybe Fingerprint
usg_exports :: Maybe Fingerprint,
usg_safe :: IsSafeImport
}
| UsageFile {
Usage -> String
usg_file_path :: FilePath,
Usage -> Fingerprint
usg_file_hash :: Fingerprint,
Usage -> Maybe String
usg_file_label :: Maybe String
}
| UsageHomeModuleInterface {
usg_mod_name :: ModuleName
, usg_unit_id :: UnitId
, Usage -> Fingerprint
usg_iface_hash :: Fingerprint
}
| UsageMergedRequirement {
usg_mod :: Module,
usg_mod_hash :: Fingerprint
}
deriving( Usage -> Usage -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Usage -> Usage -> Bool
$c/= :: Usage -> Usage -> Bool
== :: Usage -> Usage -> Bool
$c== :: Usage -> Usage -> Bool
Eq )
instance Binary Usage where
put_ :: BinHandle -> Usage -> IO ()
put_ BinHandle
bh usg :: Usage
usg@UsagePackageModule{} = do
BinHandle -> Word8 -> IO ()
putByte BinHandle
bh Word8
0
forall a. Binary a => BinHandle -> a -> IO ()
put_ BinHandle
bh (Usage -> Module
usg_mod Usage
usg)
forall a. Binary a => BinHandle -> a -> IO ()
put_ BinHandle
bh (Usage -> Fingerprint
usg_mod_hash Usage
usg)
forall a. Binary a => BinHandle -> a -> IO ()
put_ BinHandle
bh (Usage -> Bool
usg_safe Usage
usg)
put_ BinHandle
bh usg :: Usage
usg@UsageHomeModule{} = do
BinHandle -> Word8 -> IO ()
putByte BinHandle
bh Word8
1
forall a. Binary a => BinHandle -> a -> IO ()
put_ BinHandle
bh (Usage -> ModuleName
usg_mod_name Usage
usg)
forall a. Binary a => BinHandle -> a -> IO ()
put_ BinHandle
bh (Usage -> UnitId
usg_unit_id Usage
usg)
forall a. Binary a => BinHandle -> a -> IO ()
put_ BinHandle
bh (Usage -> Fingerprint
usg_mod_hash Usage
usg)
forall a. Binary a => BinHandle -> a -> IO ()
put_ BinHandle
bh (Usage -> Maybe Fingerprint
usg_exports Usage
usg)
forall a. Binary a => BinHandle -> a -> IO ()
put_ BinHandle
bh (Usage -> [(OccName, Fingerprint)]
usg_entities Usage
usg)
forall a. Binary a => BinHandle -> a -> IO ()
put_ BinHandle
bh (Usage -> Bool
usg_safe Usage
usg)
put_ BinHandle
bh usg :: Usage
usg@UsageFile{} = do
BinHandle -> Word8 -> IO ()
putByte BinHandle
bh Word8
2
forall a. Binary a => BinHandle -> a -> IO ()
put_ BinHandle
bh (Usage -> String
usg_file_path Usage
usg)
forall a. Binary a => BinHandle -> a -> IO ()
put_ BinHandle
bh (Usage -> Fingerprint
usg_file_hash Usage
usg)
forall a. Binary a => BinHandle -> a -> IO ()
put_ BinHandle
bh (Usage -> Maybe String
usg_file_label Usage
usg)
put_ BinHandle
bh usg :: Usage
usg@UsageMergedRequirement{} = do
BinHandle -> Word8 -> IO ()
putByte BinHandle
bh Word8
3
forall a. Binary a => BinHandle -> a -> IO ()
put_ BinHandle
bh (Usage -> Module
usg_mod Usage
usg)
forall a. Binary a => BinHandle -> a -> IO ()
put_ BinHandle
bh (Usage -> Fingerprint
usg_mod_hash Usage
usg)
put_ BinHandle
bh usg :: Usage
usg@UsageHomeModuleInterface{} = do
BinHandle -> Word8 -> IO ()
putByte BinHandle
bh Word8
4
forall a. Binary a => BinHandle -> a -> IO ()
put_ BinHandle
bh (Usage -> ModuleName
usg_mod_name Usage
usg)
forall a. Binary a => BinHandle -> a -> IO ()
put_ BinHandle
bh (Usage -> UnitId
usg_unit_id Usage
usg)
forall a. Binary a => BinHandle -> a -> IO ()
put_ BinHandle
bh (Usage -> Fingerprint
usg_iface_hash Usage
usg)
get :: BinHandle -> IO Usage
get BinHandle
bh = do
Word8
h <- BinHandle -> IO Word8
getByte BinHandle
bh
case Word8
h of
Word8
0 -> do
Module
nm <- forall a. Binary a => BinHandle -> IO a
get BinHandle
bh
Fingerprint
mod <- forall a. Binary a => BinHandle -> IO a
get BinHandle
bh
Bool
safe <- forall a. Binary a => BinHandle -> IO a
get BinHandle
bh
forall (m :: * -> *) a. Monad m => a -> m a
return UsagePackageModule { usg_mod :: Module
usg_mod = Module
nm, usg_mod_hash :: Fingerprint
usg_mod_hash = Fingerprint
mod, usg_safe :: Bool
usg_safe = Bool
safe }
Word8
1 -> do
ModuleName
nm <- forall a. Binary a => BinHandle -> IO a
get BinHandle
bh
UnitId
uid <- forall a. Binary a => BinHandle -> IO a
get BinHandle
bh
Fingerprint
mod <- forall a. Binary a => BinHandle -> IO a
get BinHandle
bh
Maybe Fingerprint
exps <- forall a. Binary a => BinHandle -> IO a
get BinHandle
bh
[(OccName, Fingerprint)]
ents <- forall a. Binary a => BinHandle -> IO a
get BinHandle
bh
Bool
safe <- forall a. Binary a => BinHandle -> IO a
get BinHandle
bh
forall (m :: * -> *) a. Monad m => a -> m a
return UsageHomeModule { usg_mod_name :: ModuleName
usg_mod_name = ModuleName
nm, usg_mod_hash :: Fingerprint
usg_mod_hash = Fingerprint
mod, usg_unit_id :: UnitId
usg_unit_id = UnitId
uid,
usg_exports :: Maybe Fingerprint
usg_exports = Maybe Fingerprint
exps, usg_entities :: [(OccName, Fingerprint)]
usg_entities = [(OccName, Fingerprint)]
ents, usg_safe :: Bool
usg_safe = Bool
safe }
Word8
2 -> do
String
fp <- forall a. Binary a => BinHandle -> IO a
get BinHandle
bh
Fingerprint
hash <- forall a. Binary a => BinHandle -> IO a
get BinHandle
bh
Maybe String
label <- forall a. Binary a => BinHandle -> IO a
get BinHandle
bh
forall (m :: * -> *) a. Monad m => a -> m a
return UsageFile { usg_file_path :: String
usg_file_path = String
fp, usg_file_hash :: Fingerprint
usg_file_hash = Fingerprint
hash, usg_file_label :: Maybe String
usg_file_label = Maybe String
label }
Word8
3 -> do
Module
mod <- forall a. Binary a => BinHandle -> IO a
get BinHandle
bh
Fingerprint
hash <- forall a. Binary a => BinHandle -> IO a
get BinHandle
bh
forall (m :: * -> *) a. Monad m => a -> m a
return UsageMergedRequirement { usg_mod :: Module
usg_mod = Module
mod, usg_mod_hash :: Fingerprint
usg_mod_hash = Fingerprint
hash }
Word8
4 -> do
ModuleName
mod <- forall a. Binary a => BinHandle -> IO a
get BinHandle
bh
UnitId
uid <- forall a. Binary a => BinHandle -> IO a
get BinHandle
bh
Fingerprint
hash <- forall a. Binary a => BinHandle -> IO a
get BinHandle
bh
forall (m :: * -> *) a. Monad m => a -> m a
return UsageHomeModuleInterface { usg_mod_name :: ModuleName
usg_mod_name = ModuleName
mod, usg_unit_id :: UnitId
usg_unit_id = UnitId
uid, usg_iface_hash :: Fingerprint
usg_iface_hash = Fingerprint
hash }
Word8
i -> forall a. HasCallStack => String -> a
error (String
"Binary.get(Usage): " forall a. [a] -> [a] -> [a]
++ forall a. Show a => a -> String
show Word8
i)
data ImportAvails
= ImportAvails {
ImportAvails -> ImportedMods
imp_mods :: ImportedMods,
ImportAvails -> InstalledModuleEnv (GenWithIsBoot ModuleName)
imp_direct_dep_mods :: InstalledModuleEnv ModuleNameWithIsBoot,
ImportAvails -> Set UnitId
imp_dep_direct_pkgs :: Set UnitId,
ImportAvails -> Bool
imp_trust_own_pkg :: Bool,
ImportAvails -> Set UnitId
imp_trust_pkgs :: Set UnitId,
ImportAvails -> InstalledModuleEnv (GenWithIsBoot ModuleName)
imp_boot_mods :: InstalledModuleEnv ModuleNameWithIsBoot,
ImportAvails -> [ModuleName]
imp_sig_mods :: [ModuleName],
ImportAvails -> [Module]
imp_orphs :: [Module],
ImportAvails -> [Module]
imp_finsts :: [Module]
}