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 +++- html-test/ref/PR643.html | 80 +++++++++++++++++++++++++++++ html-test/src/PR643.hs | 3 ++ html-test/src/PR643_1.hs | 7 +++ 4 files changed, 99 insertions(+), 1 deletion(-) create mode 100644 html-test/ref/PR643.html create mode 100644 html-test/src/PR643.hs create mode 100644 html-test/src/PR643_1.hs 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))] diff --git a/html-test/ref/PR643.html b/html-test/ref/PR643.html new file mode 100644 index 00000000..46e1e7ed --- /dev/null +++ b/html-test/ref/PR643.html @@ -0,0 +1,80 @@ +PR643

Safe HaskellSafe

PR643

Synopsis

Documentation

test :: () infixr 5 #

Some big documentation

\ No newline at end of file diff --git a/html-test/src/PR643.hs b/html-test/src/PR643.hs new file mode 100644 index 00000000..565e5b57 --- /dev/null +++ b/html-test/src/PR643.hs @@ -0,0 +1,3 @@ +module PR643 (test) where + +import PR643_1 diff --git a/html-test/src/PR643_1.hs b/html-test/src/PR643_1.hs new file mode 100644 index 00000000..ecd0db94 --- /dev/null +++ b/html-test/src/PR643_1.hs @@ -0,0 +1,7 @@ +module PR643_1 where + +infixr 5 `test` + +-- | Some big documentation +test :: () +test = () -- cgit v1.2.3