aboutsummaryrefslogtreecommitdiff
path: root/haddock-api/src/Haddock/GhcUtils.hs
diff options
context:
space:
mode:
Diffstat (limited to 'haddock-api/src/Haddock/GhcUtils.hs')
-rw-r--r--haddock-api/src/Haddock/GhcUtils.hs14
1 files changed, 13 insertions, 1 deletions
diff --git a/haddock-api/src/Haddock/GhcUtils.hs b/haddock-api/src/Haddock/GhcUtils.hs
index 4280cd80..02867833 100644
--- a/haddock-api/src/Haddock/GhcUtils.hs
+++ b/haddock-api/src/Haddock/GhcUtils.hs
@@ -1,4 +1,4 @@
-{-# LANGUAGE FlexibleInstances, ViewPatterns #-}
+{-# LANGUAGE BangPatterns, FlexibleInstances, ViewPatterns #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
{-# OPTIONS_HADDOCK hide #-}
-----------------------------------------------------------------------------
@@ -21,6 +21,7 @@ import Control.Arrow
import Exception
import Outputable
import Name
+import NameSet
import Lexeme
import Module
import HscTypes
@@ -135,6 +136,17 @@ declATs _ = []
pretty :: Outputable a => DynFlags -> a -> String
pretty = showPpr
+nubByName :: (a -> Name) -> [a] -> [a]
+nubByName f ns = go emptyNameSet ns
+ where
+ go !_ [] = []
+ go !s (x:xs)
+ | y `elemNameSet` s = go s xs
+ | otherwise = let !s' = extendNameSet s y
+ in x : go s' xs
+ where
+ y = f x
+
-------------------------------------------------------------------------------
-- * Located
-------------------------------------------------------------------------------