-data WhereFrom = ImportByUser -- Ordinary user import: look for M.hi
- | ImportByUserSource -- User {- SOURCE -}: look for M.hi-boot
- | ImportBySystem -- Non user import. Look for M.hi if M is in
- -- the module this module depends on, or is a system-ish module;
- -- M.hi-boot otherwise
-
-instance Outputable WhereFrom where
- ppr ImportByUser = empty
- ppr ImportByUserSource = ptext SLIT("{- SOURCE -}")
- ppr ImportBySystem = ptext SLIT("{- SYSTEM IMPORT -}")
+data ModLocation
+ = ModLocation {
+ ml_hs_file :: Maybe FilePath,
+
+ ml_hspp_file :: Maybe FilePath, -- Path of preprocessed source
+
+ ml_hi_file :: FilePath, -- Where the .hi file is, whether or not it exists
+ -- Always of form foo.hi, even if there is an hi-boot
+ -- file (we add the -boot suffix later)
+
+ ml_obj_file :: FilePath -- Where the .o file is, whether or not it exists
+ -- (might not exist either because the module
+ -- hasn't been compiled yet, or because
+ -- it is part of a package with a .a file)
+ }
+ deriving Show
+
+instance Outputable ModLocation where
+ ppr = text . show
+
+-- Rather a gruesome function to have in Module
+
+showModMsg :: Bool -> Module -> ModLocation -> String
+showModMsg use_object mod location =
+ mod_str ++ replicate (max 0 (16 - length mod_str)) ' '
+ ++" ( " ++ expectJust "showModMsg" (ml_hs_file location) ++ ", "
+ ++ (if use_object
+ then ml_obj_file location
+ else "interpreted")
+ ++ " )"
+ where mod_str = moduleUserString mod