-type LocalFindResult = MaybeErr [FilePath] FinderCacheEntry
- -- LocalFindResult is used for internal functions which
- -- return a more informative type; it's munged into
- -- the external FindResult by 'cached'
-
-cached :: Bool
- -> (DynFlags -> Module -> IO LocalFindResult)
- -> HscEnv -> Module -> Bool -> IO FindResult
-cached home_allowed wrapped_fn hsc_env name explicit
- = do { -- First try the cache
- let cache = hsc_FC hsc_env
- ; mb_entry <- lookupFinderCache cache name
- ; case mb_entry of {
- Just old_entry -> return (found old_entry) ;
- Nothing -> do
-
- { -- Now try the wrapped function
- mb_entry <- wrapped_fn (hsc_dflags hsc_env) name
- ; case mb_entry of
- Failed paths -> return (NotFound paths)
- Succeeded new_entry -> do { addToFinderCache cache name new_entry
- ; return (found new_entry) }
- }}}
- where
+findModule :: HscEnv -> Module -> Bool -> IO FindResult
+findModule = findModule' True
+
+findPackageModule :: HscEnv -> Module -> Bool -> IO FindResult
+findPackageModule = findModule' False
+
+
+data LocalFindResult
+ = Ok FinderCacheEntry
+ | CantFindAmongst [FilePath]
+ | MultiplePackages [PackageId]
+
+findModule' :: Bool -> HscEnv -> Module -> Bool -> IO FindResult
+findModule' home_allowed hsc_env name explicit
+ = do -- First try the cache
+ mb_entry <- lookupFinderCache cache name
+ case mb_entry of
+ Just old_entry -> return $! found old_entry
+ Nothing -> not_cached
+
+ where
+ cache = hsc_FC hsc_env
+ dflags = hsc_dflags hsc_env
+