[commit: haddock] pr-filter-maps: Don't include names with empty subordinates in maps (67af5a5)

git at git.haskell.org git at git.haskell.org
Mon Nov 20 21:08:40 UTC 2017


Repository : ssh://git@git.haskell.org/haddock

On branch  : pr-filter-maps
Link       : http://git.haskell.org/haddock.git/commitdiff/67af5a5a92abf34c6e77602d0314489b475fa278

>---------------------------------------------------------------

commit 67af5a5a92abf34c6e77602d0314489b475fa278
Author: Alexander Biehl <abiehl at novomind.com>
Date:   Fri Jun 23 12:48:12 2017 +0200

    Don't include names with empty subordinates in maps
    
    These are unecessary anyway and just blow up interface size


>---------------------------------------------------------------

67af5a5a92abf34c6e77602d0314489b475fa278
 haddock-api/src/Haddock/Interface/Create.hs | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/haddock-api/src/Haddock/Interface/Create.hs b/haddock-api/src/Haddock/Interface/Create.hs
index 0984894..6528d5d 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))]



More information about the ghc-commits mailing list