- | null found_exposed = return (NotFound [] Nothing mod_hiddens pkg_hiddens)
- -- found in just one exposed package:
- | [(pkg_conf, _)] <- found_exposed
- = let pkgid = mkPackageId (package pkg_conf) in
- findPackageModule_ hsc_env (mkModule pkgid mod_name) pkg_conf
- | otherwise
- = return (FoundMultiple (map (mkPackageId.package.fst) found_exposed))
- where
- dflags = hsc_dflags hsc_env
- found = lookupModuleInAllPackages dflags mod_name
-
- for_this_pkg = filter ((`matches` mb_pkg) . fst) found
-
- found_exposed = [ (pkg_conf,exposed_mod)
- | x@(pkg_conf,exposed_mod) <- for_this_pkg,
- is_exposed x ]
-
- is_exposed (pkg_conf,exposed_mod) = exposed pkg_conf && exposed_mod
-
- mod_hiddens = [ mkPackageId (package pkg_conf)
- | (pkg_conf,False) <- found ]
-
- pkg_hiddens = [ mkPackageId (package pkg_conf)
- | (pkg_conf,_) <- found, not (exposed pkg_conf) ]
-
- _pkg_conf `matches` Nothing = True
- pkg_conf `matches` Just pkg =
- case packageName pkg_conf of
- PackageName n -> pkg == mkFastString n
-
+ = case lookupModuleWithSuggestions (hsc_dflags hsc_env) mod_name of
+ Left suggest -> return (NotFound { fr_paths = [], fr_pkg = Nothing
+ , fr_pkgs_hidden = [], fr_mods_hidden = []
+ , fr_suggestions = suggest })
+ Right found
+ | null found_exposed -- Found, but with no exposed copies
+ -> return (NotFound { fr_paths = [], fr_pkg = Nothing
+ , fr_pkgs_hidden = pkg_hiddens, fr_mods_hidden = mod_hiddens
+ , fr_suggestions = [] })
+
+ | [(pkg_conf,_)] <- found_exposed -- Found uniquely
+ -> let pkgid = packageConfigId pkg_conf in
+ findPackageModule_ hsc_env (mkModule pkgid mod_name) pkg_conf
+
+ | otherwise -- Found in more than one place
+ -> return (FoundMultiple (map (packageConfigId.fst) found_exposed))
+ where
+ for_this_pkg = case mb_pkg of
+ Nothing -> found
+ Just p -> filter ((`matches` p) . fst) found
+ found_exposed = filter is_exposed for_this_pkg
+ is_exposed (pkg_conf,exposed_mod) = exposed pkg_conf && exposed_mod
+
+ mod_hiddens = [ packageConfigId pkg_conf
+ | (pkg_conf,False) <- found ]
+
+ pkg_hiddens = [ packageConfigId pkg_conf
+ | (pkg_conf,_) <- found, not (exposed pkg_conf) ]
+
+ pkg_conf `matches` pkg
+ = case packageName pkg_conf of
+ PackageName n -> pkg == mkFastString n