[commit: haddock] ghc-head, wip/T14529, wip/revert-ttg-2017-11-20, wip/ttg-2017-11-06, wip/ttg2-2017-11-10, wip/ttg3-2017-11-12, wip/ttg4-constraints-2017-11-13, wip/ttg6-unrevert-2017-11-22: Remove excessive use of list comprehensions (8a8dc2d)

git at git.haskell.org git at git.haskell.org
Tue Nov 28 11:56:05 UTC 2017


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

On branches: ghc-head,wip/T14529,wip/revert-ttg-2017-11-20,wip/ttg-2017-11-06,wip/ttg2-2017-11-10,wip/ttg3-2017-11-12,wip/ttg4-constraints-2017-11-13,wip/ttg6-unrevert-2017-11-22
Link       : http://git.haskell.org/haddock.git/commitdiff/8a8dc2de3e9004aeadbd35e11f4afed416ff35bf

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

commit 8a8dc2de3e9004aeadbd35e11f4afed416ff35bf
Author: alexbiehl <alex.biehl at gmail.com>
Date:   Tue Oct 31 22:32:31 2017 +0100

    Remove excessive use of list comprehensions


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

8a8dc2de3e9004aeadbd35e11f4afed416ff35bf
 haddock-api/src/Haddock/Interface/Create.hs | 19 +++++++------------
 1 file changed, 7 insertions(+), 12 deletions(-)

diff --git a/haddock-api/src/Haddock/Interface/Create.hs b/haddock-api/src/Haddock/Interface/Create.hs
index 096fdda..da55397 100644
--- a/haddock-api/src/Haddock/Interface/Create.hs
+++ b/haddock-api/src/Haddock/Interface/Create.hs
@@ -774,19 +774,14 @@ availExportItem is_sig modMap thisMod semMod warnings exportedNames
         name = availName avail
         -- all the exported names for this ExportItem
         exported_names = availNamesWithSelectors avail
-        subs' = [ sub
-                | sub@(sub_name, _) <- subs
-                , sub_name `elem` exported_names
-                ]
-        pats' = [ patsyn
-                | patsyn@(patsyn_decl, _) <- pats
-                , all (`elem` exported_names) (getMainDeclBinder patsyn_decl)
-                ]
+        is_exported nm = nm `elem` exported_names
+
+        subs' = filter (is_exported . fst) subs
         sub_names = map fst subs'
-        pat_names = [ n
-                    | (patsyn_decl, _) <- pats'
-                    , n <- getMainDeclBinder patsyn_decl
-                    ]
+
+        pats' = filter (all is_exported . getMainDeclBinder . fst) pats
+        pat_names = concatMap (getMainDeclBinder . fst) pats'
+
         fixities  = [ (n, f)
                     | n <- name:sub_names ++ pat_names
                     , Just f <- [M.lookup n fixMap]



More information about the ghc-commits mailing list