Nothing -> do
mod <- moduleNameToModule mn
if isHomeModule mod
- then throwDyn (UserError (showSDoc
+ then throwDyn (CmdLineError (showSDoc
(quotes (ppr (moduleName mod))
<+> text "is not currently loaded")))
else return mod
moduleNameToModule mn
= do maybe_stuff <- findModule mn
case maybe_stuff of
- Nothing -> throwDyn (UserError ("can't find module `"
+ Nothing -> throwDyn (CmdLineError ("can't find module `"
++ moduleNameUserString mn ++ "'"))
Just (m,_) -> return m
Just l | not (isObjectLinkable l) || stillThere l
-> old_linkable
-- ToDo: emit a warning if not (stillThere l)
- | otherwise
- -> Nothing
+ other -> Nothing
-- make sure that if we had an old disk linkable around, that it's
-- still there on the disk (in case we need to re-link it).
| haskellish_file file
= do exists <- doesFileExist file
if exists then summariseFile file else do
- throwDyn (UserError ("can't find file `" ++ file ++ "'"))
+ throwDyn (CmdLineError ("can't find file `" ++ file ++ "'"))
| otherwise
= do exists <- doesFileExist hs_file
if exists then summariseFile hs_file else do
let old_summary = findModInSummaries old_summaries mod
summarise mod location old_summary
- Nothing -> throwDyn (UserError
+ Nothing -> throwDyn (CmdLineError
("can't find module `"
++ showSDoc (ppr nm) ++ "'"))
summariseFile :: FilePath -> IO ModSummary
summariseFile file
= do hspp_fn <- preprocess file
- modsrc <- readFile hspp_fn
+ (srcimps,imps,mod_name) <- getImportsFromFile hspp_fn
- let (srcimps,imps,mod_name) = getImports modsrc
- (path, basename, ext) = splitFilename3 file
+ let (path, basename, ext) = splitFilename3 file
Just (mod, location)
<- mkHomeModuleLocn mod_name (path ++ '/':basename) file
-
+
src_timestamp
<- case ml_hs_file location of
Nothing -> noHsFileErr mod_name
_ -> do
hspp_fn <- preprocess hs_fn
- modsrc <- readFile hspp_fn
- let (srcimps,imps,mod_name) = getImports modsrc
+ (srcimps,imps,mod_name) <- getImportsFromFile hspp_fn
when (mod_name /= moduleName mod) $
- throwDyn (UserError
- (showSDoc (text modsrc
+ throwDyn (ProgramError
+ (showSDoc (text hs_fn
<> text ": file name does not match module name"
<+> quotes (ppr (moduleName mod)))))
= panic (showSDoc (text "no source file for module" <+> quotes (ppr mod)))
packageModErr mod
- = throwDyn (UserError (showSDoc (text "module" <+>
+ = throwDyn (CmdLineError (showSDoc (text "module" <+>
quotes (ppr mod) <+>
text "is a package module")))
\end{code}