Commit 49f7919e authored by Simon Marlow's avatar Simon Marlow
Browse files

improve the cyclic module error message as per #1856

 - remove the main: stuff
 - show the filenames
 - don't clutter the output with imports that aren't involved in
   the cycle
parent e6ca2d4a
...@@ -2318,12 +2318,19 @@ cyclicModuleErr ms ...@@ -2318,12 +2318,19 @@ cyclicModuleErr ms
= hang (ptext (sLit "Module imports form a cycle for modules:")) = hang (ptext (sLit "Module imports form a cycle for modules:"))
2 (vcat (map show_one ms)) 2 (vcat (map show_one ms))
where where
show_one ms = sep [ show_mod (ms_hsc_src ms) (ms_mod ms), mods_in_cycle = map ms_mod_name ms
nest 2 $ ptext (sLit "imports:") <+> imp_modname = unLoc . ideclName . unLoc
(pp_imps HsBootFile (ms_srcimps ms) just_in_cycle = filter ((`elem` mods_in_cycle) . imp_modname)
$$ pp_imps HsSrcFile (ms_imps ms))]
show_one ms =
vcat [ show_mod (ms_hsc_src ms) (ms_mod_name ms) <+>
maybe empty (parens . text) (ml_hs_file (ms_location ms)),
nest 2 $ ptext (sLit "imports:") <+> vcat [
pp_imps HsBootFile (just_in_cycle $ ms_srcimps ms),
pp_imps HsSrcFile (just_in_cycle $ ms_imps ms) ]
]
show_mod hsc_src mod = ppr mod <> text (hscSourceString hsc_src) show_mod hsc_src mod = ppr mod <> text (hscSourceString hsc_src)
pp_imps src mods = fsep (map (show_mod src) mods) pp_imps src imps = fsep (map (show_mod src . unLoc . ideclName . unLoc) imps)
-- | Inform GHC that the working directory has changed. GHC will flush -- | Inform GHC that the working directory has changed. GHC will flush
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment