{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE UndecidableInstances #-}
module GHC.Unit.Module.ModIface
( ModIface
, ModIface_ (..)
, PartialModIface
, ModIfaceBackend (..)
, IfaceDeclExts
, IfaceBackendExts
, IfaceExport
, WhetherHasOrphans
, WhetherHasFamInst
, mi_boot
, mi_fix
, mi_semantic_module
, mi_free_holes
, renameFreeHoles
, emptyPartialModIface
, emptyFullModIface
, mkIfaceHashCache
, emptyIfaceHashCache
)
where
import GHC.Prelude
import GHC.Hs
import GHC.Iface.Syntax
import GHC.Iface.Ext.Fields
import GHC.Unit
import GHC.Unit.Module.Deps
import GHC.Unit.Module.Warnings
import GHC.Types.Avail
import GHC.Types.Fixity
import GHC.Types.Fixity.Env
import GHC.Types.HpcInfo
import GHC.Types.Name
import GHC.Types.Name.Reader
import GHC.Types.SafeHaskell
import GHC.Types.SourceFile
import GHC.Types.Unique.DSet
import GHC.Types.Unique.FM
import GHC.Data.Maybe
import GHC.Utils.Fingerprint
import GHC.Utils.Binary
import Control.DeepSeq
type PartialModIface = ModIface_ 'ModIfaceCore
type ModIface = ModIface_ 'ModIfaceFinal
data ModIfaceBackend = ModIfaceBackend
{ ModIfaceBackend -> Fingerprint
mi_iface_hash :: !Fingerprint
, ModIfaceBackend -> Fingerprint
mi_mod_hash :: !Fingerprint
, ModIfaceBackend -> Fingerprint
mi_flag_hash :: !Fingerprint
, ModIfaceBackend -> Fingerprint
mi_opt_hash :: !Fingerprint
, ModIfaceBackend -> Fingerprint
mi_hpc_hash :: !Fingerprint
, ModIfaceBackend -> Fingerprint
mi_plugin_hash :: !Fingerprint
, ModIfaceBackend -> WhetherHasOrphans
mi_orphan :: !WhetherHasOrphans
, ModIfaceBackend -> WhetherHasOrphans
mi_finsts :: !WhetherHasFamInst
, ModIfaceBackend -> Fingerprint
mi_exp_hash :: !Fingerprint
, ModIfaceBackend -> Fingerprint
mi_orphan_hash :: !Fingerprint
, ModIfaceBackend -> OccName -> Maybe WarningTxt
mi_warn_fn :: !(OccName -> Maybe WarningTxt)
, ModIfaceBackend -> OccName -> Maybe Fixity
mi_fix_fn :: !(OccName -> Maybe Fixity)
, ModIfaceBackend -> OccName -> Maybe (OccName, Fingerprint)
mi_hash_fn :: !(OccName -> Maybe (OccName, Fingerprint))
}
data ModIfacePhase
= ModIfaceCore
| ModIfaceFinal
type family IfaceDeclExts (phase :: ModIfacePhase) where
IfaceDeclExts 'ModIfaceCore = IfaceDecl
IfaceDeclExts 'ModIfaceFinal = (Fingerprint, IfaceDecl)
type family IfaceBackendExts (phase :: ModIfacePhase) where
IfaceBackendExts 'ModIfaceCore = ()
IfaceBackendExts 'ModIfaceFinal = ModIfaceBackend
data ModIface_ (phase :: ModIfacePhase)
= ModIface {
forall (phase :: ModIfacePhase). ModIface_ phase -> Module
mi_module :: !Module,
forall (phase :: ModIfacePhase). ModIface_ phase -> Maybe Module
mi_sig_of :: !(Maybe Module),
forall (phase :: ModIfacePhase). ModIface_ phase -> HscSource
mi_hsc_src :: !HscSource,
forall (phase :: ModIfacePhase). ModIface_ phase -> Dependencies
mi_deps :: Dependencies,
forall (phase :: ModIfacePhase). ModIface_ phase -> [Usage]
mi_usages :: [Usage],
forall (phase :: ModIfacePhase). ModIface_ phase -> [IfaceExport]
mi_exports :: ![IfaceExport],
forall (phase :: ModIfacePhase).
ModIface_ phase -> WhetherHasOrphans
mi_used_th :: !Bool,
forall (phase :: ModIfacePhase).
ModIface_ phase -> [(OccName, Fixity)]
mi_fixities :: [(OccName,Fixity)],
forall (phase :: ModIfacePhase). ModIface_ phase -> Warnings
mi_warns :: Warnings,
forall (phase :: ModIfacePhase).
ModIface_ phase -> [IfaceAnnotation]
mi_anns :: [IfaceAnnotation],
forall (phase :: ModIfacePhase).
ModIface_ phase -> [IfaceDeclExts phase]
mi_decls :: [IfaceDeclExts phase],
forall (phase :: ModIfacePhase).
ModIface_ phase -> Maybe GlobalRdrEnv
mi_globals :: !(Maybe GlobalRdrEnv),
forall (phase :: ModIfacePhase). ModIface_ phase -> [IfaceClsInst]
mi_insts :: [IfaceClsInst],
forall (phase :: ModIfacePhase). ModIface_ phase -> [IfaceFamInst]
mi_fam_insts :: [IfaceFamInst],
forall (phase :: ModIfacePhase). ModIface_ phase -> [IfaceRule]
mi_rules :: [IfaceRule],
forall (phase :: ModIfacePhase).
ModIface_ phase -> WhetherHasOrphans
mi_hpc :: !AnyHpcUsage,
forall (phase :: ModIfacePhase). ModIface_ phase -> IfaceTrustInfo
mi_trust :: !IfaceTrustInfo,
forall (phase :: ModIfacePhase).
ModIface_ phase -> WhetherHasOrphans
mi_trust_pkg :: !Bool,
forall (phase :: ModIfacePhase).
ModIface_ phase -> [IfaceCompleteMatch]
mi_complete_matches :: [IfaceCompleteMatch],
forall (phase :: ModIfacePhase).
ModIface_ phase -> Maybe HsDocString
mi_doc_hdr :: Maybe HsDocString,
forall (phase :: ModIfacePhase). ModIface_ phase -> DeclDocMap
mi_decl_docs :: DeclDocMap,
forall (phase :: ModIfacePhase). ModIface_ phase -> ArgDocMap
mi_arg_docs :: ArgDocMap,
forall (phase :: ModIfacePhase).
ModIface_ phase -> IfaceBackendExts phase
mi_final_exts :: !(IfaceBackendExts phase),
forall (phase :: ModIfacePhase).
ModIface_ phase -> ExtensibleFields
mi_ext_fields :: ExtensibleFields
}
mi_boot :: ModIface -> IsBootInterface
mi_boot :: ModIface -> IsBootInterface
mi_boot ModIface
iface = if ModIface -> HscSource
forall (phase :: ModIfacePhase). ModIface_ phase -> HscSource
mi_hsc_src ModIface
iface HscSource -> HscSource -> WhetherHasOrphans
forall a. Eq a => a -> a -> WhetherHasOrphans
== HscSource
HsBootFile
then IsBootInterface
IsBoot
else IsBootInterface
NotBoot
mi_fix :: ModIface -> OccName -> Fixity
mi_fix :: ModIface -> OccName -> Fixity
mi_fix ModIface
iface OccName
name = ModIfaceBackend -> OccName -> Maybe Fixity
mi_fix_fn (ModIface -> IfaceBackendExts 'ModIfaceFinal
forall (phase :: ModIfacePhase).
ModIface_ phase -> IfaceBackendExts phase
mi_final_exts ModIface
iface) OccName
name Maybe Fixity -> Fixity -> Fixity
forall a. Maybe a -> a -> a
`orElse` Fixity
defaultFixity
mi_semantic_module :: ModIface_ a -> Module
mi_semantic_module :: forall (phase :: ModIfacePhase). ModIface_ phase -> Module
mi_semantic_module ModIface_ a
iface = case ModIface_ a -> Maybe Module
forall (phase :: ModIfacePhase). ModIface_ phase -> Maybe Module
mi_sig_of ModIface_ a
iface of
Maybe Module
Nothing -> ModIface_ a -> Module
forall (phase :: ModIfacePhase). ModIface_ phase -> Module
mi_module ModIface_ a
iface
Just Module
mod -> Module
mod
mi_free_holes :: ModIface -> UniqDSet ModuleName
mi_free_holes :: ModIface -> UniqDSet ModuleName
mi_free_holes ModIface
iface =
case Module -> (InstalledModule, Maybe InstantiatedModule)
getModuleInstantiation (ModIface -> Module
forall (phase :: ModIfacePhase). ModIface_ phase -> Module
mi_module ModIface
iface) of
(InstalledModule
_, Just InstantiatedModule
indef)
-> UniqDSet ModuleName
-> [(ModuleName, Module)] -> UniqDSet ModuleName
renameFreeHoles ([ModuleName] -> UniqDSet ModuleName
forall a. Uniquable a => [a] -> UniqDSet a
mkUniqDSet [ModuleName]
cands) (GenInstantiatedUnit UnitId -> [(ModuleName, Module)]
forall unit. GenInstantiatedUnit unit -> GenInstantiations unit
instUnitInsts (InstantiatedModule -> GenInstantiatedUnit UnitId
forall unit. GenModule unit -> unit
moduleUnit InstantiatedModule
indef))
(InstalledModule, Maybe InstantiatedModule)
_ -> UniqDSet ModuleName
forall a. UniqDSet a
emptyUniqDSet
where
cands :: [ModuleName]
cands = (GenWithIsBoot ModuleName -> ModuleName)
-> [GenWithIsBoot ModuleName] -> [ModuleName]
forall a b. (a -> b) -> [a] -> [b]
map GenWithIsBoot ModuleName -> ModuleName
forall mod. GenWithIsBoot mod -> mod
gwib_mod ([GenWithIsBoot ModuleName] -> [ModuleName])
-> [GenWithIsBoot ModuleName] -> [ModuleName]
forall a b. (a -> b) -> a -> b
$ Dependencies -> [GenWithIsBoot ModuleName]
dep_mods (Dependencies -> [GenWithIsBoot ModuleName])
-> Dependencies -> [GenWithIsBoot ModuleName]
forall a b. (a -> b) -> a -> b
$ ModIface -> Dependencies
forall (phase :: ModIfacePhase). ModIface_ phase -> Dependencies
mi_deps ModIface
iface
renameFreeHoles :: UniqDSet ModuleName -> [(ModuleName, Module)] -> UniqDSet ModuleName
renameFreeHoles :: UniqDSet ModuleName
-> [(ModuleName, Module)] -> UniqDSet ModuleName
renameFreeHoles UniqDSet ModuleName
fhs [(ModuleName, Module)]
insts =
[UniqDSet ModuleName] -> UniqDSet ModuleName
forall a. [UniqDSet a] -> UniqDSet a
unionManyUniqDSets ((ModuleName -> UniqDSet ModuleName)
-> [ModuleName] -> [UniqDSet ModuleName]
forall a b. (a -> b) -> [a] -> [b]
map ModuleName -> UniqDSet ModuleName
lookup_impl (UniqDSet ModuleName -> [ModuleName]
forall a. UniqDSet a -> [a]
uniqDSetToList UniqDSet ModuleName
fhs))
where
hmap :: UniqFM ModuleName Module
hmap = [(ModuleName, Module)] -> UniqFM ModuleName Module
forall key elt. Uniquable key => [(key, elt)] -> UniqFM key elt
listToUFM [(ModuleName, Module)]
insts
lookup_impl :: ModuleName -> UniqDSet ModuleName
lookup_impl ModuleName
mod_name
| Just Module
mod <- UniqFM ModuleName Module -> ModuleName -> Maybe Module
forall key elt. Uniquable key => UniqFM key elt -> key -> Maybe elt
lookupUFM UniqFM ModuleName Module
hmap ModuleName
mod_name = Module -> UniqDSet ModuleName
forall u. GenModule (GenUnit u) -> UniqDSet ModuleName
moduleFreeHoles Module
mod
| WhetherHasOrphans
otherwise = UniqDSet ModuleName
forall a. UniqDSet a
emptyUniqDSet
instance Binary ModIface where
put_ :: BinHandle -> ModIface -> IO ()
put_ BinHandle
bh (ModIface {
mi_module :: forall (phase :: ModIfacePhase). ModIface_ phase -> Module
mi_module = Module
mod,
mi_sig_of :: forall (phase :: ModIfacePhase). ModIface_ phase -> Maybe Module
mi_sig_of = Maybe Module
sig_of,
mi_hsc_src :: forall (phase :: ModIfacePhase). ModIface_ phase -> HscSource
mi_hsc_src = HscSource
hsc_src,
mi_deps :: forall (phase :: ModIfacePhase). ModIface_ phase -> Dependencies
mi_deps = Dependencies
deps,
mi_usages :: forall (phase :: ModIfacePhase). ModIface_ phase -> [Usage]
mi_usages = [Usage]
usages,
mi_exports :: forall (phase :: ModIfacePhase). ModIface_ phase -> [IfaceExport]
mi_exports = [IfaceExport]
exports,
mi_used_th :: forall (phase :: ModIfacePhase).
ModIface_ phase -> WhetherHasOrphans
mi_used_th = WhetherHasOrphans
used_th,
mi_fixities :: forall (phase :: ModIfacePhase).
ModIface_ phase -> [(OccName, Fixity)]
mi_fixities = [(OccName, Fixity)]
fixities,
mi_warns :: forall (phase :: ModIfacePhase). ModIface_ phase -> Warnings
mi_warns = Warnings
warns,
mi_anns :: forall (phase :: ModIfacePhase).
ModIface_ phase -> [IfaceAnnotation]
mi_anns = [IfaceAnnotation]
anns,
mi_decls :: forall (phase :: ModIfacePhase).
ModIface_ phase -> [IfaceDeclExts phase]
mi_decls = [IfaceDeclExts 'ModIfaceFinal]
decls,
mi_insts :: forall (phase :: ModIfacePhase). ModIface_ phase -> [IfaceClsInst]
mi_insts = [IfaceClsInst]
insts,
mi_fam_insts :: forall (phase :: ModIfacePhase). ModIface_ phase -> [IfaceFamInst]
mi_fam_insts = [IfaceFamInst]
fam_insts,
mi_rules :: forall (phase :: ModIfacePhase). ModIface_ phase -> [IfaceRule]
mi_rules = [IfaceRule]
rules,
mi_hpc :: forall (phase :: ModIfacePhase).
ModIface_ phase -> WhetherHasOrphans
mi_hpc = WhetherHasOrphans
hpc_info,
mi_trust :: forall (phase :: ModIfacePhase). ModIface_ phase -> IfaceTrustInfo
mi_trust = IfaceTrustInfo
trust,
mi_trust_pkg :: forall (phase :: ModIfacePhase).
ModIface_ phase -> WhetherHasOrphans
mi_trust_pkg = WhetherHasOrphans
trust_pkg,
mi_complete_matches :: forall (phase :: ModIfacePhase).
ModIface_ phase -> [IfaceCompleteMatch]
mi_complete_matches = [IfaceCompleteMatch]
complete_matches,
mi_doc_hdr :: forall (phase :: ModIfacePhase).
ModIface_ phase -> Maybe HsDocString
mi_doc_hdr = Maybe HsDocString
doc_hdr,
mi_decl_docs :: forall (phase :: ModIfacePhase). ModIface_ phase -> DeclDocMap
mi_decl_docs = DeclDocMap
decl_docs,
mi_arg_docs :: forall (phase :: ModIfacePhase). ModIface_ phase -> ArgDocMap
mi_arg_docs = ArgDocMap
arg_docs,
mi_ext_fields :: forall (phase :: ModIfacePhase).
ModIface_ phase -> ExtensibleFields
mi_ext_fields = ExtensibleFields
_ext_fields,
mi_final_exts :: forall (phase :: ModIfacePhase).
ModIface_ phase -> IfaceBackendExts phase
mi_final_exts = ModIfaceBackend {
mi_iface_hash :: ModIfaceBackend -> Fingerprint
mi_iface_hash = Fingerprint
iface_hash,
mi_mod_hash :: ModIfaceBackend -> Fingerprint
mi_mod_hash = Fingerprint
mod_hash,
mi_flag_hash :: ModIfaceBackend -> Fingerprint
mi_flag_hash = Fingerprint
flag_hash,
mi_opt_hash :: ModIfaceBackend -> Fingerprint
mi_opt_hash = Fingerprint
opt_hash,
mi_hpc_hash :: ModIfaceBackend -> Fingerprint
mi_hpc_hash = Fingerprint
hpc_hash,
mi_plugin_hash :: ModIfaceBackend -> Fingerprint
mi_plugin_hash = Fingerprint
plugin_hash,
mi_orphan :: ModIfaceBackend -> WhetherHasOrphans
mi_orphan = WhetherHasOrphans
orphan,
mi_finsts :: ModIfaceBackend -> WhetherHasOrphans
mi_finsts = WhetherHasOrphans
hasFamInsts,
mi_exp_hash :: ModIfaceBackend -> Fingerprint
mi_exp_hash = Fingerprint
exp_hash,
mi_orphan_hash :: ModIfaceBackend -> Fingerprint
mi_orphan_hash = Fingerprint
orphan_hash
}}) = do
BinHandle -> Module -> IO ()
forall a. Binary a => BinHandle -> a -> IO ()
put_ BinHandle
bh Module
mod
BinHandle -> Maybe Module -> IO ()
forall a. Binary a => BinHandle -> a -> IO ()
put_ BinHandle
bh Maybe Module
sig_of
BinHandle -> HscSource -> IO ()
forall a. Binary a => BinHandle -> a -> IO ()
put_ BinHandle
bh HscSource
hsc_src
BinHandle -> Fingerprint -> IO ()
forall a. Binary a => BinHandle -> a -> IO ()
put_ BinHandle
bh Fingerprint
iface_hash
BinHandle -> Fingerprint -> IO ()
forall a. Binary a => BinHandle -> a -> IO ()
put_ BinHandle
bh Fingerprint
mod_hash
BinHandle -> Fingerprint -> IO ()
forall a. Binary a => BinHandle -> a -> IO ()
put_ BinHandle
bh Fingerprint
flag_hash
BinHandle -> Fingerprint -> IO ()
forall a. Binary a => BinHandle -> a -> IO ()
put_ BinHandle
bh Fingerprint
opt_hash
BinHandle -> Fingerprint -> IO ()
forall a. Binary a => BinHandle -> a -> IO ()
put_ BinHandle
bh Fingerprint
hpc_hash
BinHandle -> Fingerprint -> IO ()
forall a. Binary a => BinHandle -> a -> IO ()
put_ BinHandle
bh Fingerprint
plugin_hash
BinHandle -> WhetherHasOrphans -> IO ()
forall a. Binary a => BinHandle -> a -> IO ()
put_ BinHandle
bh WhetherHasOrphans
orphan
BinHandle -> WhetherHasOrphans -> IO ()
forall a. Binary a => BinHandle -> a -> IO ()
put_ BinHandle
bh WhetherHasOrphans
hasFamInsts
BinHandle -> Dependencies -> IO ()
forall a. Binary a => BinHandle -> a -> IO ()
lazyPut BinHandle
bh Dependencies
deps
BinHandle -> [Usage] -> IO ()
forall a. Binary a => BinHandle -> a -> IO ()
lazyPut BinHandle
bh [Usage]
usages
BinHandle -> [IfaceExport] -> IO ()
forall a. Binary a => BinHandle -> a -> IO ()
put_ BinHandle
bh [IfaceExport]
exports
BinHandle -> Fingerprint -> IO ()
forall a. Binary a => BinHandle -> a -> IO ()
put_ BinHandle
bh Fingerprint
exp_hash
BinHandle -> WhetherHasOrphans -> IO ()
forall a. Binary a => BinHandle -> a -> IO ()
put_ BinHandle
bh WhetherHasOrphans
used_th
BinHandle -> [(OccName, Fixity)] -> IO ()
forall a. Binary a => BinHandle -> a -> IO ()
put_ BinHandle
bh [(OccName, Fixity)]
fixities
BinHandle -> Warnings -> IO ()
forall a. Binary a => BinHandle -> a -> IO ()
lazyPut BinHandle
bh Warnings
warns
BinHandle -> [IfaceAnnotation] -> IO ()
forall a. Binary a => BinHandle -> a -> IO ()
lazyPut BinHandle
bh [IfaceAnnotation]
anns
BinHandle -> [(Fingerprint, IfaceDecl)] -> IO ()
forall a. Binary a => BinHandle -> a -> IO ()
put_ BinHandle
bh [(Fingerprint, IfaceDecl)]
[IfaceDeclExts 'ModIfaceFinal]
decls
BinHandle -> [IfaceClsInst] -> IO ()
forall a. Binary a => BinHandle -> a -> IO ()
put_ BinHandle
bh [IfaceClsInst]
insts
BinHandle -> [IfaceFamInst] -> IO ()
forall a. Binary a => BinHandle -> a -> IO ()
put_ BinHandle
bh [IfaceFamInst]
fam_insts
BinHandle -> [IfaceRule] -> IO ()
forall a. Binary a => BinHandle -> a -> IO ()
lazyPut BinHandle
bh [IfaceRule]
rules
BinHandle -> Fingerprint -> IO ()
forall a. Binary a => BinHandle -> a -> IO ()
put_ BinHandle
bh Fingerprint
orphan_hash
BinHandle -> WhetherHasOrphans -> IO ()
forall a. Binary a => BinHandle -> a -> IO ()
put_ BinHandle
bh WhetherHasOrphans
hpc_info
BinHandle -> IfaceTrustInfo -> IO ()
forall a. Binary a => BinHandle -> a -> IO ()
put_ BinHandle
bh IfaceTrustInfo
trust
BinHandle -> WhetherHasOrphans -> IO ()
forall a. Binary a => BinHandle -> a -> IO ()
put_ BinHandle
bh WhetherHasOrphans
trust_pkg
BinHandle -> [IfaceCompleteMatch] -> IO ()
forall a. Binary a => BinHandle -> a -> IO ()
put_ BinHandle
bh [IfaceCompleteMatch]
complete_matches
BinHandle -> Maybe HsDocString -> IO ()
forall a. Binary a => BinHandle -> a -> IO ()
lazyPut BinHandle
bh Maybe HsDocString
doc_hdr
BinHandle -> DeclDocMap -> IO ()
forall a. Binary a => BinHandle -> a -> IO ()
lazyPut BinHandle
bh DeclDocMap
decl_docs
BinHandle -> ArgDocMap -> IO ()
forall a. Binary a => BinHandle -> a -> IO ()
lazyPut BinHandle
bh ArgDocMap
arg_docs
get :: BinHandle -> IO ModIface
get BinHandle
bh = do
Module
mod <- BinHandle -> IO Module
forall a. Binary a => BinHandle -> IO a
get BinHandle
bh
Maybe Module
sig_of <- BinHandle -> IO (Maybe Module)
forall a. Binary a => BinHandle -> IO a
get BinHandle
bh
HscSource
hsc_src <- BinHandle -> IO HscSource
forall a. Binary a => BinHandle -> IO a
get BinHandle
bh
Fingerprint
iface_hash <- BinHandle -> IO Fingerprint
forall a. Binary a => BinHandle -> IO a
get BinHandle
bh
Fingerprint
mod_hash <- BinHandle -> IO Fingerprint
forall a. Binary a => BinHandle -> IO a
get BinHandle
bh
Fingerprint
flag_hash <- BinHandle -> IO Fingerprint
forall a. Binary a => BinHandle -> IO a
get BinHandle
bh
Fingerprint
opt_hash <- BinHandle -> IO Fingerprint
forall a. Binary a => BinHandle -> IO a
get BinHandle
bh
Fingerprint
hpc_hash <- BinHandle -> IO Fingerprint
forall a. Binary a => BinHandle -> IO a
get BinHandle
bh
Fingerprint
plugin_hash <- BinHandle -> IO Fingerprint
forall a. Binary a => BinHandle -> IO a
get BinHandle
bh
WhetherHasOrphans
orphan <- BinHandle -> IO WhetherHasOrphans
forall a. Binary a => BinHandle -> IO a
get BinHandle
bh
WhetherHasOrphans
hasFamInsts <- BinHandle -> IO WhetherHasOrphans
forall a. Binary a => BinHandle -> IO a
get BinHandle
bh
Dependencies
deps <- BinHandle -> IO Dependencies
forall a. Binary a => BinHandle -> IO a
lazyGet BinHandle
bh
[Usage]
usages <- {-# SCC "bin_usages" #-} BinHandle -> IO [Usage]
forall a. Binary a => BinHandle -> IO a
lazyGet BinHandle
bh
[IfaceExport]
exports <- {-# SCC "bin_exports" #-} BinHandle -> IO [IfaceExport]
forall a. Binary a => BinHandle -> IO a
get BinHandle
bh
Fingerprint
exp_hash <- BinHandle -> IO Fingerprint
forall a. Binary a => BinHandle -> IO a
get BinHandle
bh
WhetherHasOrphans
used_th <- BinHandle -> IO WhetherHasOrphans
forall a. Binary a => BinHandle -> IO a
get BinHandle
bh
[(OccName, Fixity)]
fixities <- {-# SCC "bin_fixities" #-} BinHandle -> IO [(OccName, Fixity)]
forall a. Binary a => BinHandle -> IO a
get BinHandle
bh
Warnings
warns <- {-# SCC "bin_warns" #-} BinHandle -> IO Warnings
forall a. Binary a => BinHandle -> IO a
lazyGet BinHandle
bh
[IfaceAnnotation]
anns <- {-# SCC "bin_anns" #-} BinHandle -> IO [IfaceAnnotation]
forall a. Binary a => BinHandle -> IO a
lazyGet BinHandle
bh
[(Fingerprint, IfaceDecl)]
decls <- {-# SCC "bin_tycldecls" #-} BinHandle -> IO [(Fingerprint, IfaceDecl)]
forall a. Binary a => BinHandle -> IO a
get BinHandle
bh
[IfaceClsInst]
insts <- {-# SCC "bin_insts" #-} BinHandle -> IO [IfaceClsInst]
forall a. Binary a => BinHandle -> IO a
get BinHandle
bh
[IfaceFamInst]
fam_insts <- {-# SCC "bin_fam_insts" #-} BinHandle -> IO [IfaceFamInst]
forall a. Binary a => BinHandle -> IO a
get BinHandle
bh
[IfaceRule]
rules <- {-# SCC "bin_rules" #-} BinHandle -> IO [IfaceRule]
forall a. Binary a => BinHandle -> IO a
lazyGet BinHandle
bh
Fingerprint
orphan_hash <- BinHandle -> IO Fingerprint
forall a. Binary a => BinHandle -> IO a
get BinHandle
bh
WhetherHasOrphans
hpc_info <- BinHandle -> IO WhetherHasOrphans
forall a. Binary a => BinHandle -> IO a
get BinHandle
bh
IfaceTrustInfo
trust <- BinHandle -> IO IfaceTrustInfo
forall a. Binary a => BinHandle -> IO a
get BinHandle
bh
WhetherHasOrphans
trust_pkg <- BinHandle -> IO WhetherHasOrphans
forall a. Binary a => BinHandle -> IO a
get BinHandle
bh
[IfaceCompleteMatch]
complete_matches <- BinHandle -> IO [IfaceCompleteMatch]
forall a. Binary a => BinHandle -> IO a
get BinHandle
bh
Maybe HsDocString
doc_hdr <- BinHandle -> IO (Maybe HsDocString)
forall a. Binary a => BinHandle -> IO a
lazyGet BinHandle
bh
DeclDocMap
decl_docs <- BinHandle -> IO DeclDocMap
forall a. Binary a => BinHandle -> IO a
lazyGet BinHandle
bh
ArgDocMap
arg_docs <- BinHandle -> IO ArgDocMap
forall a. Binary a => BinHandle -> IO a
lazyGet BinHandle
bh
ModIface -> IO ModIface
forall (m :: * -> *) a. Monad m => a -> m a
return (ModIface {
mi_module :: Module
mi_module = Module
mod,
mi_sig_of :: Maybe Module
mi_sig_of = Maybe Module
sig_of,
mi_hsc_src :: HscSource
mi_hsc_src = HscSource
hsc_src,
mi_deps :: Dependencies
mi_deps = Dependencies
deps,
mi_usages :: [Usage]
mi_usages = [Usage]
usages,
mi_exports :: [IfaceExport]
mi_exports = [IfaceExport]
exports,
mi_used_th :: WhetherHasOrphans
mi_used_th = WhetherHasOrphans
used_th,
mi_anns :: [IfaceAnnotation]
mi_anns = [IfaceAnnotation]
anns,
mi_fixities :: [(OccName, Fixity)]
mi_fixities = [(OccName, Fixity)]
fixities,
mi_warns :: Warnings
mi_warns = Warnings
warns,
mi_decls :: [IfaceDeclExts 'ModIfaceFinal]
mi_decls = [(Fingerprint, IfaceDecl)]
[IfaceDeclExts 'ModIfaceFinal]
decls,
mi_globals :: Maybe GlobalRdrEnv
mi_globals = Maybe GlobalRdrEnv
forall a. Maybe a
Nothing,
mi_insts :: [IfaceClsInst]
mi_insts = [IfaceClsInst]
insts,
mi_fam_insts :: [IfaceFamInst]
mi_fam_insts = [IfaceFamInst]
fam_insts,
mi_rules :: [IfaceRule]
mi_rules = [IfaceRule]
rules,
mi_hpc :: WhetherHasOrphans
mi_hpc = WhetherHasOrphans
hpc_info,
mi_trust :: IfaceTrustInfo
mi_trust = IfaceTrustInfo
trust,
mi_trust_pkg :: WhetherHasOrphans
mi_trust_pkg = WhetherHasOrphans
trust_pkg,
mi_complete_matches :: [IfaceCompleteMatch]
mi_complete_matches = [IfaceCompleteMatch]
complete_matches,
mi_doc_hdr :: Maybe HsDocString
mi_doc_hdr = Maybe HsDocString
doc_hdr,
mi_decl_docs :: DeclDocMap
mi_decl_docs = DeclDocMap
decl_docs,
mi_arg_docs :: ArgDocMap
mi_arg_docs = ArgDocMap
arg_docs,
mi_ext_fields :: ExtensibleFields
mi_ext_fields = ExtensibleFields
emptyExtensibleFields,
mi_final_exts :: IfaceBackendExts 'ModIfaceFinal
mi_final_exts = ModIfaceBackend {
mi_iface_hash :: Fingerprint
mi_iface_hash = Fingerprint
iface_hash,
mi_mod_hash :: Fingerprint
mi_mod_hash = Fingerprint
mod_hash,
mi_flag_hash :: Fingerprint
mi_flag_hash = Fingerprint
flag_hash,
mi_opt_hash :: Fingerprint
mi_opt_hash = Fingerprint
opt_hash,
mi_hpc_hash :: Fingerprint
mi_hpc_hash = Fingerprint
hpc_hash,
mi_plugin_hash :: Fingerprint
mi_plugin_hash = Fingerprint
plugin_hash,
mi_orphan :: WhetherHasOrphans
mi_orphan = WhetherHasOrphans
orphan,
mi_finsts :: WhetherHasOrphans
mi_finsts = WhetherHasOrphans
hasFamInsts,
mi_exp_hash :: Fingerprint
mi_exp_hash = Fingerprint
exp_hash,
mi_orphan_hash :: Fingerprint
mi_orphan_hash = Fingerprint
orphan_hash,
mi_warn_fn :: OccName -> Maybe WarningTxt
mi_warn_fn = Warnings -> OccName -> Maybe WarningTxt
mkIfaceWarnCache Warnings
warns,
mi_fix_fn :: OccName -> Maybe Fixity
mi_fix_fn = [(OccName, Fixity)] -> OccName -> Maybe Fixity
mkIfaceFixCache [(OccName, Fixity)]
fixities,
mi_hash_fn :: OccName -> Maybe (OccName, Fingerprint)
mi_hash_fn = [(Fingerprint, IfaceDecl)]
-> OccName -> Maybe (OccName, Fingerprint)
mkIfaceHashCache [(Fingerprint, IfaceDecl)]
decls
}})
type IfaceExport = AvailInfo
emptyPartialModIface :: Module -> PartialModIface
emptyPartialModIface :: Module -> PartialModIface
emptyPartialModIface Module
mod
= ModIface { mi_module :: Module
mi_module = Module
mod,
mi_sig_of :: Maybe Module
mi_sig_of = Maybe Module
forall a. Maybe a
Nothing,
mi_hsc_src :: HscSource
mi_hsc_src = HscSource
HsSrcFile,
mi_deps :: Dependencies
mi_deps = Dependencies
noDependencies,
mi_usages :: [Usage]
mi_usages = [],
mi_exports :: [IfaceExport]
mi_exports = [],
mi_used_th :: WhetherHasOrphans
mi_used_th = WhetherHasOrphans
False,
mi_fixities :: [(OccName, Fixity)]
mi_fixities = [],
mi_warns :: Warnings
mi_warns = Warnings
NoWarnings,
mi_anns :: [IfaceAnnotation]
mi_anns = [],
mi_insts :: [IfaceClsInst]
mi_insts = [],
mi_fam_insts :: [IfaceFamInst]
mi_fam_insts = [],
mi_rules :: [IfaceRule]
mi_rules = [],
mi_decls :: [IfaceDeclExts 'ModIfaceCore]
mi_decls = [],
mi_globals :: Maybe GlobalRdrEnv
mi_globals = Maybe GlobalRdrEnv
forall a. Maybe a
Nothing,
mi_hpc :: WhetherHasOrphans
mi_hpc = WhetherHasOrphans
False,
mi_trust :: IfaceTrustInfo
mi_trust = IfaceTrustInfo
noIfaceTrustInfo,
mi_trust_pkg :: WhetherHasOrphans
mi_trust_pkg = WhetherHasOrphans
False,
mi_complete_matches :: [IfaceCompleteMatch]
mi_complete_matches = [],
mi_doc_hdr :: Maybe HsDocString
mi_doc_hdr = Maybe HsDocString
forall a. Maybe a
Nothing,
mi_decl_docs :: DeclDocMap
mi_decl_docs = DeclDocMap
emptyDeclDocMap,
mi_arg_docs :: ArgDocMap
mi_arg_docs = ArgDocMap
emptyArgDocMap,
mi_final_exts :: IfaceBackendExts 'ModIfaceCore
mi_final_exts = (),
mi_ext_fields :: ExtensibleFields
mi_ext_fields = ExtensibleFields
emptyExtensibleFields
}
emptyFullModIface :: Module -> ModIface
emptyFullModIface :: Module -> ModIface
emptyFullModIface Module
mod =
(Module -> PartialModIface
emptyPartialModIface Module
mod)
{ mi_decls :: [IfaceDeclExts 'ModIfaceFinal]
mi_decls = []
, mi_final_exts :: IfaceBackendExts 'ModIfaceFinal
mi_final_exts = ModIfaceBackend
{ mi_iface_hash :: Fingerprint
mi_iface_hash = Fingerprint
fingerprint0,
mi_mod_hash :: Fingerprint
mi_mod_hash = Fingerprint
fingerprint0,
mi_flag_hash :: Fingerprint
mi_flag_hash = Fingerprint
fingerprint0,
mi_opt_hash :: Fingerprint
mi_opt_hash = Fingerprint
fingerprint0,
mi_hpc_hash :: Fingerprint
mi_hpc_hash = Fingerprint
fingerprint0,
mi_plugin_hash :: Fingerprint
mi_plugin_hash = Fingerprint
fingerprint0,
mi_orphan :: WhetherHasOrphans
mi_orphan = WhetherHasOrphans
False,
mi_finsts :: WhetherHasOrphans
mi_finsts = WhetherHasOrphans
False,
mi_exp_hash :: Fingerprint
mi_exp_hash = Fingerprint
fingerprint0,
mi_orphan_hash :: Fingerprint
mi_orphan_hash = Fingerprint
fingerprint0,
mi_warn_fn :: OccName -> Maybe WarningTxt
mi_warn_fn = OccName -> Maybe WarningTxt
emptyIfaceWarnCache,
mi_fix_fn :: OccName -> Maybe Fixity
mi_fix_fn = OccName -> Maybe Fixity
emptyIfaceFixCache,
mi_hash_fn :: OccName -> Maybe (OccName, Fingerprint)
mi_hash_fn = OccName -> Maybe (OccName, Fingerprint)
emptyIfaceHashCache } }
mkIfaceHashCache :: [(Fingerprint,IfaceDecl)]
-> (OccName -> Maybe (OccName, Fingerprint))
mkIfaceHashCache :: [(Fingerprint, IfaceDecl)]
-> OccName -> Maybe (OccName, Fingerprint)
mkIfaceHashCache [(Fingerprint, IfaceDecl)]
pairs
= \OccName
occ -> OccEnv (OccName, Fingerprint)
-> OccName -> Maybe (OccName, Fingerprint)
forall a. OccEnv a -> OccName -> Maybe a
lookupOccEnv OccEnv (OccName, Fingerprint)
env OccName
occ
where
env :: OccEnv (OccName, Fingerprint)
env = (OccEnv (OccName, Fingerprint)
-> (Fingerprint, IfaceDecl) -> OccEnv (OccName, Fingerprint))
-> OccEnv (OccName, Fingerprint)
-> [(Fingerprint, IfaceDecl)]
-> OccEnv (OccName, Fingerprint)
forall (t :: * -> *) b a.
Foldable t =>
(b -> a -> b) -> b -> t a -> b
foldl' OccEnv (OccName, Fingerprint)
-> (Fingerprint, IfaceDecl) -> OccEnv (OccName, Fingerprint)
add_decl OccEnv (OccName, Fingerprint)
forall a. OccEnv a
emptyOccEnv [(Fingerprint, IfaceDecl)]
pairs
add_decl :: OccEnv (OccName, Fingerprint)
-> (Fingerprint, IfaceDecl) -> OccEnv (OccName, Fingerprint)
add_decl OccEnv (OccName, Fingerprint)
env0 (Fingerprint
v,IfaceDecl
d) = (OccEnv (OccName, Fingerprint)
-> (OccName, Fingerprint) -> OccEnv (OccName, Fingerprint))
-> OccEnv (OccName, Fingerprint)
-> [(OccName, Fingerprint)]
-> OccEnv (OccName, Fingerprint)
forall (t :: * -> *) b a.
Foldable t =>
(b -> a -> b) -> b -> t a -> b
foldl' OccEnv (OccName, Fingerprint)
-> (OccName, Fingerprint) -> OccEnv (OccName, Fingerprint)
forall {b}.
OccEnv (OccName, b) -> (OccName, b) -> OccEnv (OccName, b)
add OccEnv (OccName, Fingerprint)
env0 (Fingerprint -> IfaceDecl -> [(OccName, Fingerprint)]
ifaceDeclFingerprints Fingerprint
v IfaceDecl
d)
where
add :: OccEnv (OccName, b) -> (OccName, b) -> OccEnv (OccName, b)
add OccEnv (OccName, b)
env0 (OccName
occ,b
hash) = OccEnv (OccName, b)
-> OccName -> (OccName, b) -> OccEnv (OccName, b)
forall a. OccEnv a -> OccName -> a -> OccEnv a
extendOccEnv OccEnv (OccName, b)
env0 OccName
occ (OccName
occ,b
hash)
emptyIfaceHashCache :: OccName -> Maybe (OccName, Fingerprint)
emptyIfaceHashCache :: OccName -> Maybe (OccName, Fingerprint)
emptyIfaceHashCache OccName
_occ = Maybe (OccName, Fingerprint)
forall a. Maybe a
Nothing
instance (NFData (IfaceBackendExts (phase :: ModIfacePhase)), NFData (IfaceDeclExts (phase :: ModIfacePhase))) => NFData (ModIface_ phase) where
rnf :: ModIface_ phase -> ()
rnf (ModIface Module
f1 Maybe Module
f2 HscSource
f3 Dependencies
f4 [Usage]
f5 [IfaceExport]
f6 WhetherHasOrphans
f7 [(OccName, Fixity)]
f8 Warnings
f9 [IfaceAnnotation]
f10 [IfaceDeclExts phase]
f11 Maybe GlobalRdrEnv
f12
[IfaceClsInst]
f13 [IfaceFamInst]
f14 [IfaceRule]
f15 WhetherHasOrphans
f16 IfaceTrustInfo
f17 WhetherHasOrphans
f18 [IfaceCompleteMatch]
f19 Maybe HsDocString
f20 DeclDocMap
f21 ArgDocMap
f22 IfaceBackendExts phase
f23 ExtensibleFields
f24) =
Module -> ()
forall a. NFData a => a -> ()
rnf Module
f1 () -> () -> ()
`seq` Maybe Module -> ()
forall a. NFData a => a -> ()
rnf Maybe Module
f2 () -> () -> ()
`seq` HscSource
f3 HscSource -> () -> ()
`seq` Dependencies
f4 Dependencies -> () -> ()
`seq` [Usage]
f5 [Usage] -> () -> ()
`seq` [IfaceExport]
f6 [IfaceExport] -> () -> ()
`seq` WhetherHasOrphans -> ()
forall a. NFData a => a -> ()
rnf WhetherHasOrphans
f7 () -> () -> ()
`seq` [(OccName, Fixity)]
f8 [(OccName, Fixity)] -> () -> ()
`seq`
Warnings
f9 Warnings -> () -> ()
`seq` [IfaceAnnotation] -> ()
forall a. NFData a => a -> ()
rnf [IfaceAnnotation]
f10 () -> () -> ()
`seq` [IfaceDeclExts phase] -> ()
forall a. NFData a => a -> ()
rnf [IfaceDeclExts phase]
f11 () -> () -> ()
`seq` Maybe GlobalRdrEnv
f12 Maybe GlobalRdrEnv -> () -> ()
`seq` [IfaceClsInst] -> ()
forall a. NFData a => a -> ()
rnf [IfaceClsInst]
f13 () -> () -> ()
`seq` [IfaceFamInst] -> ()
forall a. NFData a => a -> ()
rnf [IfaceFamInst]
f14 () -> () -> ()
`seq` [IfaceRule] -> ()
forall a. NFData a => a -> ()
rnf [IfaceRule]
f15 () -> () -> ()
`seq`
WhetherHasOrphans -> ()
forall a. NFData a => a -> ()
rnf WhetherHasOrphans
f16 () -> () -> ()
`seq` IfaceTrustInfo
f17 IfaceTrustInfo -> () -> ()
`seq` WhetherHasOrphans -> ()
forall a. NFData a => a -> ()
rnf WhetherHasOrphans
f18 () -> () -> ()
`seq` [IfaceCompleteMatch] -> ()
forall a. NFData a => a -> ()
rnf [IfaceCompleteMatch]
f19 () -> () -> ()
`seq` Maybe HsDocString
f20 Maybe HsDocString -> () -> ()
`seq` DeclDocMap
f21 DeclDocMap -> () -> ()
`seq` ArgDocMap
f22 ArgDocMap -> () -> ()
`seq` IfaceBackendExts phase -> ()
forall a. NFData a => a -> ()
rnf IfaceBackendExts phase
f23
() -> () -> ()
`seq` ExtensibleFields -> ()
forall a. NFData a => a -> ()
rnf ExtensibleFields
f24
type WhetherHasOrphans = Bool
type WhetherHasFamInst = Bool