_not_a_home_module -> do
maybe_stuff <- findModule mn
case maybe_stuff of
- Nothing -> throwDyn (CmdLineError ("can't find module `"
+ Left _ -> throwDyn (CmdLineError ("can't find module `"
++ moduleNameUserString mn ++ "'"))
- Just (m,_) -> return m
+ Right (m,_) -> return m
cmGetContext :: CmState -> IO ([String],[String])
cmGetContext CmState{ic=ic} =
cmInfoThing :: CmState -> DynFlags -> String -> IO (CmState, [(TyThing,Fixity)])
cmInfoThing cmstate dflags id
= do (new_pcs, things) <- hscThing hsc_env pcs icontext id
- let pairs = map (\x -> (x, getFixity new_pcs (getName x))) things
+ let new_pit = eps_PIT (pcs_EPS new_pcs)
+ pairs = map (\x -> (x, getFixity new_pit (getName x))) things
return (cmstate{ pcs=new_pcs }, pairs)
where
CmState{ hpt=hpt, pcs=pcs, ic=icontext } = cmstate
hsc_env = HscEnv { hsc_mode = Interactive,
hsc_dflags = dflags,
hsc_HPT = hpt }
- pit = eps_PIT (pcs_EPS pcs)
- getFixity :: PersistentCompilerState -> Name -> Fixity
- getFixity pcs name
+
+ getFixity :: PackageIfaceTable -> Name -> Fixity
+ getFixity pit name
| isExternalName name,
Just iface <- lookupIface hpt pit (nameModule name),
Just (FixitySig _ fixity _) <- lookupNameEnv (mi_fixities iface) name
= do showPass dflags "Chasing dependencies"
when (verbosity dflags >= 1 && gmode cmstate == Batch) $
hPutStrLn stderr (showSDoc (hcat [
- text progName, text ": chasing modules from: ",
+ text "Chasing modules from: ",
hcat (punctuate comma (map text rootnames))]))
downsweep rootnames (mg cmstate)
valid_old_linkables
when (verb >= 2) $
- putStrLn (showSDoc (text "Stable modules:"
+ hPutStrLn stderr (showSDoc (text "Stable modules:"
<+> sep (map (text.moduleNameUserString) stable_mods)))
-- Unload any modules which are going to be re-linked this
hPutStrLn stderr "Warning: output was redirected with -o, but no output will be generated\nbecause there is no Main module."
-- link everything together
- linkresult <- link ghci_mode dflags a_root_is_Main (hptLinkables hpt3)
+ linkresult <- link ghci_mode dflags a_root_is_Main hpt3
cmLoadFinish Succeeded linkresult
hpt3 modsDone ghci_mode pcs3
cleanTempFilesExcept verb (ppFilesFromSummaries mods_to_keep)
-- Link everything together
- linkresult <- link ghci_mode dflags False (hptLinkables hpt4)
+ linkresult <- link ghci_mode dflags False hpt4
cmLoadFinish Failed linkresult
hpt4 mods_to_keep ghci_mode pcs3
getSummary (currentMod,nm)
= do found <- findModule nm
case found of
- Just (mod, location) -> do
+ Right (mod, location) -> do
let old_summary = findModInSummaries old_summaries mod
summarise mod location old_summary
- Nothing ->
- throwDyn (CmdLineError
- ("can't find module `"
- ++ showSDoc (ppr nm) ++ "' (while processing "
- ++ show currentMod ++ ")"))
+ Left files -> do
+ dflags <- getDynFlags
+ throwDyn (noModError dflags currentMod nm files)
-- loop invariant: env doesn't contain package modules
loop :: [(FilePath,ModuleName)] -> ModuleEnv ModSummary -> IO [ModSummary]
loop new_imps (extendModuleEnvList env
[ (ms_mod s, s) | s <- new_home_summaries ])
+-- ToDo: we don't have a proper line number for this error
+noModError dflags loc mod_nm files = ProgramError (showSDoc (
+ hang (text loc <> colon) 4 $
+ (text "Can't find module" <+> quotes (ppr mod_nm) $$ extra)
+ ))
+ where
+ extra
+ | verbosity dflags < 3 =
+ text "(use -v to see a list of the files searched for)"
+ | otherwise =
+ hang (ptext SLIT("locations searched:")) 4 (vcat (map text files))
+
-----------------------------------------------------------------------------
-- Summarising modules