From 2d919a367139482cd76398ca1e90dff6f5427779 Mon Sep 17 00:00:00 2001 From: Alex Biehl Date: Fri, 23 Jun 2017 18:30:45 +0200 Subject: Don't include names with empty subordinates in maps (#644) These are unecessary anyway and just blow up interface size --- haddock-api/src/Haddock/Interface/Create.hs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'haddock-api/src/Haddock/Interface') 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))] -- cgit v1.2.3