@@ -653,7 +653,7 @@ setupFinderCache mss session = do
653
653
-- Make modules available for others that import them,
654
654
-- by putting them in the finder cache.
655
655
let ims = map (installedModule (homeUnitId_ $ hsc_dflags session) . moduleName . ms_mod) mss
656
- ifrs = zipWith (\ ms -> InstalledFound (ms_location ms) ) mss ims
656
+ ifrs = zipWith (InstalledFound . ms_location ) mss ims
657
657
-- set the target and module graph in the session
658
658
graph = mkModuleGraph mss
659
659
@@ -967,23 +967,25 @@ getDocsBatch
967
967
-> [Name ]
968
968
-> IO [Either String (Maybe HsDocString , Map. Map Int HsDocString )]
969
969
getDocsBatch hsc_env _mod _names = do
970
- ((_warns,errs), res) <- initTc hsc_env HsSrcFile False _mod fakeSpan $ forM _names $ \ name ->
970
+ ((_warns,errs), res) <- initTc hsc_env HsSrcFile False _mod fakeSpan $ traverse findNameInfo _names
971
+ case res of
972
+ Just x -> return $ map (first $ T. unpack . showGhc) x
973
+ Nothing -> throwErrors errs
974
+ where
975
+ throwErrors = liftIO . throwIO . mkSrcErr
976
+
977
+ findNameInfo :: Name -> IOEnv (Env TcGblEnv TcLclEnv ) (Either GetDocsFailure (Maybe HsDocString , Map. Map Int HsDocString ))
978
+ findNameInfo name =
971
979
case nameModule_maybe name of
972
980
Nothing -> return (Left $ NameHasNoModule name)
973
981
Just mod -> do
974
982
ModIface { mi_doc_hdr = mb_doc_hdr
975
983
, mi_decl_docs = DeclDocMap dmap
976
984
, mi_arg_docs = ArgDocMap amap
977
985
} <- loadModuleInterface " getModuleInterface" mod
978
- if isNothing mb_doc_hdr && Map. null dmap && Map. null amap
979
- then pure (Left (NoDocsInIface mod $ compiled name))
980
- else pure (Right ( Map. lookup name dmap
981
- , Map. findWithDefault Map. empty name amap))
982
- case res of
983
- Just x -> return $ map (first $ T. unpack . showGhc) x
984
- Nothing -> throwErrors errs
985
- where
986
- throwErrors = liftIO . throwIO . mkSrcErr
986
+ pure $ if isNothing mb_doc_hdr && Map. null dmap && Map. null amap
987
+ then Left (NoDocsInIface mod $ compiled name)
988
+ else Right (Map. lookup name dmap, Map. findWithDefault mempty name amap)
987
989
compiled n =
988
990
-- TODO: Find a more direct indicator.
989
991
case nameSrcLoc n of
0 commit comments