+ not_found_in_package pkg files
+ | build_tag /= ""
+ = let
+ build = if build_tag == "p" then "profiling"
+ else "\"" ++ build_tag ++ "\""
+ in
+ ptext (sLit "Perhaps you haven't installed the ") <> text build <>
+ ptext (sLit " libraries for package ") <> quotes (ppr pkg) <> char '?' $$
+ tried_these files
+
+ | otherwise
+ = ptext (sLit "There are files missing in the ") <> quotes (ppr pkg) <>
+ ptext (sLit " package,") $$
+ ptext (sLit "try running 'ghc-pkg check'.") $$
+ tried_these files
+
+ tried_these files
+ | null files = empty
+ | verbosity dflags < 3 =
+ ptext (sLit "Use -v to see a list of the files searched for.")
+ | otherwise =
+ hang (ptext (sLit "Locations searched:")) 2 $ vcat (map text files)
+
+ pkg_hidden pkg =
+ ptext (sLit "It is a member of the hidden package") <+> quotes (ppr pkg)
+ <> dot $$ cabal_pkg_hidden_hint pkg
+ cabal_pkg_hidden_hint pkg
+ | dopt Opt_BuildingCabalPackage dflags
+ = case simpleParse (packageIdString pkg) of
+ Just pid ->
+ ptext (sLit "Perhaps you need to add") <+>
+ quotes (text (display (pkgName pid))) <+>
+ ptext (sLit "to the build-depends in your .cabal file.")
+ Nothing -> empty
+ | otherwise = empty
+
+ mod_hidden pkg =
+ ptext (sLit "it is a hidden module in the package") <+> quotes (ppr pkg)
+
+ pp_suggestions :: [Module] -> SDoc
+ pp_suggestions sugs
+ | null sugs = empty
+ | otherwise = hang (ptext (sLit "Perhaps you meant"))
+ 2 (vcat [ vcat (map pp_exp exposed_sugs)
+ , vcat (map pp_hid hidden_sugs) ])
+ where
+ (exposed_sugs, hidden_sugs) = partition from_exposed_pkg sugs
+
+ from_exposed_pkg m = case lookupPackage pkg_map (modulePackageId m) of
+ Just pkg_config -> exposed pkg_config
+ Nothing -> WARN( True, ppr m ) -- Should not happen
+ False
+
+ pp_exp mod = ppr (moduleName mod)
+ <+> parens (ptext (sLit "from") <+> ppr (modulePackageId mod))
+ pp_hid mod = ppr (moduleName mod)
+ <+> parens (ptext (sLit "needs flag -package") <+> ppr (modulePackageId mod))