summaryrefslogtreecommitdiff
path: root/compiler/GHC/Iface/Load.hs
diff options
context:
space:
mode:
authorJohn Ericson <John.Ericson@Obsidian.Systems>2020-04-30 11:07:15 -0400
committerMarge Bot <ben+marge-bot@smart-cactus.org>2020-06-04 04:34:42 -0400
commit32a4ae90b50cc56f2955f489ad0cf8c7ff5e131a (patch)
tree274e86d49420a09eb8400bc3751c55f827ed4e56 /compiler/GHC/Iface/Load.hs
parentcb5c31b51b021ce86890bba73276fe6f7405f5d3 (diff)
downloadhaskell-32a4ae90b50cc56f2955f489ad0cf8c7ff5e131a.tar.gz
Clean up boot vs non-boot disambiguating types
We often have (ModuleName, Bool) or (Module, Bool) pairs for "extended" module names (without or with a unit id) disambiguating boot and normal modules. We think this is important enough across the compiler that it deserves a new nominal product type. We do this with synnoyms and a functor named with a `Gen` prefix, matching other newly created definitions. It was also requested that we keep custom `IsBoot` / `NotBoot` sum type. So we have it too. This means changing many the many bools to use that instead. Updates `haddock` submodule.
Diffstat (limited to 'compiler/GHC/Iface/Load.hs')
-rw-r--r--compiler/GHC/Iface/Load.hs26
1 files changed, 14 insertions, 12 deletions
diff --git a/compiler/GHC/Iface/Load.hs b/compiler/GHC/Iface/Load.hs
index 80c4505c8e..ef69e97605 100644
--- a/compiler/GHC/Iface/Load.hs
+++ b/compiler/GHC/Iface/Load.hs
@@ -366,7 +366,7 @@ loadSysInterface doc mod_name = loadInterfaceWithException doc mod_name ImportBy
------------------
-- | Loads a user interface and throws an exception if it fails. The first parameter indicates
-- whether we should import the boot variant of the module
-loadUserInterface :: Bool -> SDoc -> Module -> IfM lcl ModIface
+loadUserInterface :: IsBootInterface -> SDoc -> Module -> IfM lcl ModIface
loadUserInterface is_boot doc mod_name
= loadInterfaceWithException doc mod_name (ImportByUser is_boot)
@@ -485,7 +485,7 @@ loadInterface doc_str mod from
}
}
- ; let bad_boot = mi_boot iface && fmap fst (if_rec_types gbl_env) == Just mod
+ ; let bad_boot = mi_boot iface == IsBoot && fmap fst (if_rec_types gbl_env) == Just mod
-- Warn warn against an EPS-updating import
-- of one's own boot file! (one-shot only)
-- See Note [Loading your own hi-boot file]
@@ -690,7 +690,7 @@ moduleFreeHolesPrecise doc_str mod
Just ifhs -> Just (renameFreeHoles ifhs insts)
_otherwise -> Nothing
readAndCache imod insts = do
- mb_iface <- findAndReadIface (text "moduleFreeHolesPrecise" <+> doc_str) imod mod False
+ mb_iface <- findAndReadIface (text "moduleFreeHolesPrecise" <+> doc_str) imod mod NotBoot
case mb_iface of
Succeeded (iface, _) -> do
let ifhs = mi_free_holes iface
@@ -706,23 +706,25 @@ wantHiBootFile :: DynFlags -> ExternalPackageState -> Module -> WhereFrom
wantHiBootFile dflags eps mod from
= case from of
ImportByUser usr_boot
- | usr_boot && not this_package
+ | usr_boot == IsBoot && not this_package
-> Failed (badSourceImport mod)
| otherwise -> Succeeded usr_boot
ImportByPlugin
- -> Succeeded False
+ -> Succeeded NotBoot
ImportBySystem
| not this_package -- If the module to be imported is not from this package
- -> Succeeded False -- don't look it up in eps_is_boot, because that is keyed
+ -> Succeeded NotBoot -- don't look it up in eps_is_boot, because that is keyed
-- on the ModuleName of *home-package* modules only.
-- We never import boot modules from other packages!
| otherwise
-> case lookupUFM (eps_is_boot eps) (moduleName mod) of
- Just (_, is_boot) -> Succeeded is_boot
- Nothing -> Succeeded False
+ Just (GWIB { gwib_isBoot = is_boot }) ->
+ Succeeded is_boot
+ Nothing ->
+ Succeeded NotBoot
-- The boot-ness of the requested interface,
-- based on the dependencies in directly-imported modules
where
@@ -899,7 +901,7 @@ findAndReadIface :: SDoc
-- sometimes it's ok to fail... see notes with loadInterface
findAndReadIface doc_str mod wanted_mod_with_insts hi_boot_file
= do traceIf (sep [hsep [text "Reading",
- if hi_boot_file
+ if hi_boot_file == IsBoot
then text "[boot]"
else Outputable.empty,
text "interface for",
@@ -1219,11 +1221,11 @@ pprDeps (Deps { dep_mods = mods, dep_pkgs = pkgs, dep_orphs = orphs,
text "family instance modules:" <+> fsep (map ppr finsts)
]
where
- ppr_mod (mod_name, boot) = ppr mod_name <+> ppr_boot boot
+ ppr_mod (GWIB { gwib_mod = mod_name, gwib_isBoot = boot }) = ppr mod_name <+> ppr_boot boot
ppr_pkg (pkg,trust_req) = ppr pkg <>
(if trust_req then text "*" else Outputable.empty)
- ppr_boot True = text "[boot]"
- ppr_boot False = Outputable.empty
+ ppr_boot IsBoot = text "[boot]"
+ ppr_boot NotBoot = Outputable.empty
pprFixities :: [(OccName, Fixity)] -> SDoc
pprFixities [] = Outputable.empty