getLocalNameEnv `thenRn` \ name_env ->
(if opt_WarnNameShadowing
then
- mapRn (check_shadow name_env) rdr_names_w_loc
+ mapRn_ (check_shadow name_env) rdr_names_w_loc
else
- returnRn []
+ returnRn ()
) `thenRn_`
newLocalNames rdr_names_w_loc `thenRn` \ names ->
checkDupOrQualNames doc_str rdr_names_w_loc
= -- Check for use of qualified names
- mapRn (qualNameErr doc_str) quals `thenRn_`
+ mapRn_ (qualNameErr doc_str) quals `thenRn_`
checkDupNames doc_str rdr_names_w_loc
where
quals = filter (isQual.fst) rdr_names_w_loc
checkDupNames doc_str rdr_names_w_loc
- = -- Check for dupicated names in a binding group
- mapRn (dupNamesErr doc_str) dups `thenRn_`
- returnRn ()
+ = -- Check for duplicated names in a binding group
+ mapRn_ (dupNamesErr doc_str) dups
where
(_, dups) = removeDups (\(n1,l1) (n2,l2) -> n1 `compare` n2) rdr_names_w_loc
\end{code}
Nothing -> getModeRn `thenRn` \ mode ->
case mode of
-- Not found when processing source code; so fail
- SourceMode -> failWithRn (mkUnboundName rdr_name)
- (unknownNameErr rdr_name)
+ SourceMode -> failUnboundNameErrRn rdr_name
-- Not found when processing an imported declaration,
-- so we create a new name for the purpose
warnUnusedBinds :: (Bool -> Bool) -> [Name] -> RnM s d ()
warnUnusedBinds warn_when_local names
- = mapRn (warnUnusedGroup warn_when_local) groups `thenRn_`
- returnRn ()
+ = mapRn_ (warnUnusedGroup warn_when_local) groups
where
-- Group by provenance
groups = equivClasses cmp names
= case getNameProvenance name1 of
LocalDef loc _ -> (True, loc, text "Defined but not used")
NonLocalDef (UserImport mod loc _) _ -> (True, loc, text "Imported from" <+> quotes (ppr mod) <+>
- text "but but not used")
+ text "but not used")
other -> (False, getSrcLoc name1, text "Strangely defined but not used")
\end{code}
4 (vcat [ppr how_in_scope1,
ppr how_in_scope2])
+failUnboundNameErrRn :: RdrName -> RnM s d Name
+failUnboundNameErrRn rdr_name =
+ failWithRn (mkUnboundName rdr_name)
+ (unknownNameErr rdr_name)
+
shadowedNameWarn shadow
= hsep [ptext SLIT("This binding for"),
quotes (ppr shadow),