)
import Module ( Module, moduleString, pprModule,
mkVanillaModule, pprModuleName,
- moduleUserString, moduleName, isLibModule,
+ moduleUserString, moduleName, isPrelModule,
ModuleName, WhereFrom(..),
)
import RdrName ( RdrName, rdrNameOcc )
mod_map_result ->
-- READ THE MODULE IN
- findAndReadIface doc_str mod_name from below_me
- `thenRn` \ (hi_boot_read, read_result) ->
+ findAndReadIface doc_str mod_name from below_me `thenRn` \ (hi_boot_read, read_result) ->
case read_result of {
Nothing -> -- Not found, so add an empty export env to the Ifaces map
-- so that we don't look again
addModDeps mod mod_deps new_deps
= foldr add mod_deps new_deps
where
- is_lib = isLibModule mod -- Don't record dependencies when importing a library module
+ is_lib = isPrelModule mod -- Don't record dependencies when importing a prelude module
add (imp_mod, version, has_orphans, is_boot, _) deps
| is_lib && not has_orphans = deps
| otherwise = addToFM_C combine deps imp_mod (version, has_orphans, is_boot, Nothing)
-- either are dependent via a non-library module
-- or contain orphan rules or instance decls
- -- Don't ditch a module that's already loaded
- -- If it isn't loaded, and together the is_boot-ness
- combine old@(_, _, _, Just _) new = old
- combine old@(_, _, old_is_boot, Nothing)
- new@(version, has_orphans, new_is_boot, _)
- = (version, has_orphans, old_is_boot && new_is_boot, Nothing)
+ combine old@(_, _, old_is_boot, cts) new
+ | maybeToBool cts || not old_is_boot = old -- Keep the old info if it's already loaded
+ -- or if it's a non-boot pending load
+ | otherwise = new -- Otherwise pick new info
loadExport :: ModuleName -> ExportItem -> RnM d [AvailInfo]
loadExport this_mod (mod, entities)
-- I can't be bothered just now.
mk_version_info mod_name (version, has_orphans, is_boot, contents) so_far
+ | mod_name == this_mod -- Check if M appears in the set of modules 'below' M
+ -- This seems like a convenient place to check
+ = WARN( not is_boot, ptext SLIT("Wierd:") <+> ppr this_mod <+>
+ ptext SLIT("imports itself (perhaps indirectly)") )
+ so_far
+
+ | otherwise
= let
go_for_it exports = (mod_name, version, has_orphans, is_boot, exports)
: so_far
-- but don't actually *use* anything from Foo
-- In which case record an empty dependency list
where
- is_lib_module = isLibModule mod
+ is_lib_module = isPrelModule mod
in
- -- A module shouldn't load its own interface
- -- This seems like a convenient place to check
- WARN( maybeToBool (lookupFM mod_map this_mod),
- ptext SLIT("Wierd:") <+> ppr this_mod <+> ptext SLIT("loads its own interface") )
returnRn (foldFM mk_version_info [] mod_map)
where
(False, lookupFM hi_map mod_name)
| otherwise
- -- Check if there's a library module of that name
+ -- Check if there's a prelude module of that name
-- If not, look for an hi-boot file
= case lookupFM hi_map mod_name of
- stuff@(Just (_, mod)) | isLibModule mod -> (False, stuff)
- other -> (True, lookupFM hiboot_map mod_name)
+ stuff@(Just (_, mod)) | isPrelModule mod -> (False, stuff)
+ other -> (True, lookupFM hiboot_map mod_name)
trace_msg = sep [hsep [ptext SLIT("Reading"),
ppr from,
text (show err)]
getDeclErr name
- = ptext SLIT("Failed to find interface decl for") <+> quotes (ppr name)
+ = vcat [ptext SLIT("Failed to find interface decl for") <+> quotes (ppr name),
+ ptext SLIT("from module") <+> quotes (ppr (nameModule name))
+ ]
getDeclWarn name loc
= sep [ptext SLIT("Failed to find (optional) interface decl for") <+> quotes (ppr name),