aboutsummaryrefslogtreecommitdiff
path: root/haddock-api/src/Haddock
diff options
context:
space:
mode:
authorAlex Biehl <alexbiehl@gmail.com>2017-06-23 18:30:45 +0200
committerGitHub <noreply@github.com>2017-06-23 18:30:45 +0200
commit2d919a367139482cd76398ca1e90dff6f5427779 (patch)
tree40a7faef20a633d831d8e098f02c2b6bfbfe61c0 /haddock-api/src/Haddock
parentcf7addb983bd2079b221199f8ec09c8edaeb8956 (diff)
Don't include names with empty subordinates in maps (#644)
These are unecessary anyway and just blow up interface size
Diffstat (limited to 'haddock-api/src/Haddock')
-rw-r--r--haddock-api/src/Haddock/Interface/Create.hs10
1 files changed, 9 insertions, 1 deletions
diff --git a/haddock-api/src/Haddock/Interface/Create.hs b/haddock-api/src/Haddock/Interface/Create.hs
index 0984894d..50643e2a 100644
--- a/haddock-api/src/Haddock/Interface/Create.hs
+++ b/haddock-api/src/Haddock/Interface/Create.hs
@@ -317,7 +317,12 @@ mkMaps :: DynFlags
mkMaps dflags gre instances decls =
let
(a, b, c, d) = unzip4 $ map mappings decls
- in (f' $ map (nubByName fst) a , f b, f c, f d, instanceMap)
+ in ( f' (map (nubByName fst) a)
+ , f (filterMapping (not . M.null) b)
+ , f (filterMapping (not . null) c)
+ , f (filterMapping (not . null) d)
+ , instanceMap
+ )
where
f :: (Ord a, Monoid b) => [[(a, b)]] -> Map a b
f = M.fromListWith (<>) . concat
@@ -325,6 +330,9 @@ mkMaps dflags gre instances decls =
f' :: [[(Name, MDoc Name)]] -> Map Name (MDoc Name)
f' = M.fromListWith metaDocAppend . concat
+ filterMapping :: (b -> Bool) -> [[(a, b)]] -> [[(a, b)]]
+ filterMapping p = map (filter (p . snd))
+
mappings :: (LHsDecl Name, [HsDocString])
-> ( [(Name, MDoc Name)]
, [(Name, Map Int (MDoc Name))]