refactoring Browse.
This commit is contained in:
parent
8fe6c99131
commit
9796d639ab
20
Browse.hs
20
Browse.hs
@ -44,21 +44,19 @@ browse opt mdlName = withGHC $ do
|
|||||||
processModule :: ModuleInfo -> Ghc [String]
|
processModule :: ModuleInfo -> Ghc [String]
|
||||||
processModule minfo = do
|
processModule minfo = do
|
||||||
dynFlags <- getDynFlags
|
dynFlags <- getDynFlags
|
||||||
let processName :: Name -> Ghc String
|
mapM (processName dynFlags) names
|
||||||
processName nm = do
|
where
|
||||||
|
names = modInfoExports minfo
|
||||||
|
processName :: DynFlags -> Name -> Ghc String
|
||||||
|
processName dynFlags nm = do
|
||||||
tyInfo <- modInfoLookupName minfo nm
|
tyInfo <- modInfoLookupName minfo nm
|
||||||
-- If nothing found, load dependent module and lookup global
|
-- If nothing found, load dependent module and lookup global
|
||||||
tyResult <- maybe inOtherModule (return . Just) tyInfo
|
tyResult <- maybe (inOtherModule nm) (return . Just) tyInfo
|
||||||
return $ fromMaybe name (tyResult >>= showThing dynFlags)
|
return $ fromMaybe (getOccString nm) (tyResult >>= showThing dynFlags)
|
||||||
where
|
inOtherModule :: Name -> Ghc (Maybe TyThing)
|
||||||
inOtherModule :: Ghc (Maybe TyThing)
|
inOtherModule nm = do
|
||||||
inOtherModule = do
|
|
||||||
_ <- getModuleInfo (nameModule nm) -- FIXME
|
_ <- getModuleInfo (nameModule nm) -- FIXME
|
||||||
lookupGlobalName nm
|
lookupGlobalName nm
|
||||||
name = getOccString nm
|
|
||||||
mapM processName exports
|
|
||||||
where
|
|
||||||
exports = modInfoExports minfo
|
|
||||||
|
|
||||||
showThing :: DynFlags -> TyThing -> Maybe String
|
showThing :: DynFlags -> TyThing -> Maybe String
|
||||||
showThing dflags t = case t of
|
showThing dflags t = case t of
|
||||||
|
Loading…
Reference in New Issue
Block a user