+loadHiBootInterface :: TcRn [Name]
+-- Load the hi-boot iface for the module being compiled,
+-- if it indeed exists in the transitive closure of imports
+-- Return the list of names exported by the hi-boot file
+loadHiBootInterface
+ = do { eps <- getEps
+ ; mod <- getModule
+
+ ; traceIf (text "loadHiBootInterface" <+> ppr mod)
+
+ -- We're read all the direct imports by now, so eps_is_boot will
+ -- record if any of our imports mention us by way of hi-boot file
+ ; case lookupModuleEnv (eps_is_boot eps) mod of {
+ Nothing -> return [] ; -- The typical case
+
+ Just (_, False) -> -- Someone below us imported us!
+ -- This is a loop with no hi-boot in the way
+ failWithTc (moduleLoop mod) ;
+
+ Just (mod_nm, True) -> -- There's a hi-boot interface below us
+
+
+ do { -- Load it (into the PTE, and return the exported names
+ iface <- loadSrcInterface (mk_doc mod_nm) mod_nm True
+ ; sequenceM [ lookupOrig mod_nm occ
+ | (mod,avails) <- mi_exports iface,
+ avail <- avails, occ <- availNames avail]
+ }}}
+ where
+ mk_doc mod = ptext SLIT("Need the hi-boot interface for") <+> ppr mod
+ <+> ptext SLIT("to compare against the Real Thing")
+
+ moduleLoop mod = ptext SLIT("Circular imports: module") <+> quotes (ppr mod)
+ <+> ptext SLIT("depends on itself")
+
+loadOrphanModules :: [Module] -> TcM ()