From d0fabd7e923e7a73913dd18d55d34caada3890fe Mon Sep 17 00:00:00 2001 From: Simon Hengel Date: Thu, 17 May 2012 18:49:39 +0200 Subject: Simplify lookupWarning --- src/Haddock/Interface/Create.hs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'src/Haddock') diff --git a/src/Haddock/Interface/Create.hs b/src/Haddock/Interface/Create.hs index 1513349f..bc9bf3e0 100644 --- a/src/Haddock/Interface/Create.hs +++ b/src/Haddock/Interface/Create.hs @@ -164,15 +164,17 @@ lookupModuleDyn dflags Nothing mdlName = ------------------------------------------------------------------------------- --- FIXME: simplify lookupWarning :: Warnings -> GlobalRdrEnv -> Name -> Maybe (Doc id) lookupWarning NoWarnings _ _ = Nothing lookupWarning (WarnAll _) _ _ = Nothing -lookupWarning (WarnSome ws) gre name = M.lookup name wm - where - wm = M.fromList - [ (n, warnToDoc w) | (occ, w) <- ws, elt <- lookupGlobalRdrEnv gre occ - , let n = gre_name elt, n == name ] +lookupWarning (WarnSome ws) gre name = + -- there is at most one warning for each name, so it's fine to use + -- listToMaybe here + listToMaybe [warnToDoc w + | (occ, w) <- ws + , elt <- lookupGlobalRdrEnv gre occ + , gre_name elt == name + ] moduleWarning :: Warnings -> Maybe (Doc id) -- cgit v1.2.3