-addHomeModuleToFinder :: Module -> ModLocation -> IO ()
-addHomeModuleToFinder mod loc = addToFinderCache mod (loc, Nothing)
-
-
--- -----------------------------------------------------------------------------
--- The two external entry points
-
-
-findModule :: DynFlags -> Module -> Bool -> IO FindResult
-findModule = cached findModule'
-
-findPackageModule :: DynFlags -> Module -> Bool -> IO FindResult
-findPackageModule = cached findPackageModule'
+ found_new entry = do
+ addToFinderCache cache name entry
+ return $! found entry
+
+ not_cached
+ | not home_allowed = do
+ j <- findPackageModule' dflags name
+ case j of
+ Ok entry -> found_new entry
+ MultiplePackages pkgs -> return (FoundMultiple pkgs)
+ CantFindAmongst paths -> return (NotFound paths)
+
+ | otherwise = do
+ j <- findHomeModule' dflags name
+ case j of
+ Ok entry -> found_new entry
+ MultiplePackages pkgs -> return (FoundMultiple pkgs)
+ CantFindAmongst home_files -> do
+ r <- findPackageModule' dflags name
+ case r of
+ CantFindAmongst pkg_files ->
+ return (NotFound (home_files ++ pkg_files))
+ MultiplePackages pkgs ->
+ return (FoundMultiple pkgs)
+ Ok entry ->
+ found_new entry
+
+addHomeModuleToFinder :: HscEnv -> Module -> ModLocation -> IO ()
+addHomeModuleToFinder hsc_env mod loc
+ = addToFinderCache (hsc_FC hsc_env) mod (loc, Nothing)
+
+uncacheModule :: HscEnv -> Module -> IO ()
+uncacheModule hsc_env mod = removeFromFinderCache (hsc_FC hsc_env) mod