aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSimon Hengel <sol@typeful.net>2012-05-17 18:49:39 +0200
committerSimon Hengel <sol@typeful.net>2012-05-17 19:08:20 +0200
commitd0fabd7e923e7a73913dd18d55d34caada3890fe (patch)
tree815152e5a1b857ca3a0d0fcc1684a66374b873d8 /src
parenta6bcb1e464ff33161f84c5794f5ae239604fb7e5 (diff)
Simplify lookupWarning
Diffstat (limited to 'src')
-rw-r--r--src/Haddock/Interface/Create.hs14
1 files changed, 8 insertions, 6 deletions
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)