@@ -16,16 +16,16 @@ import Language.Haskell.Names.ScopeUtils
1616import Language.Haskell.Names.SyntaxUtils
1717import Language.Haskell.Names.ModuleSymbols
1818import Language.Haskell.Names.GlobalSymbolTable as Global
19- import Data.List ( nub )
19+ import qualified Data.Set as Set ( fromList , toList )
2020
2121
2222-- | Compute the list of symbols the given module exports using the given
2323-- table of symbols that are in scope in that module.
2424exportedSymbols :: (Data l , Eq l ) => Global. Table -> Module l -> [Symbol ]
25- exportedSymbols globalTable modul = case getExportSpecList modul of
25+ exportedSymbols globalTable modul = nubSymbols ( case getExportSpecList modul of
2626 Nothing -> moduleSymbols globalTable modul
2727 Just (ExportSpecList _ exportSpecs) ->
28- concatMap (exportSpecSymbols globalTable) exportSpecs
28+ concatMap (exportSpecSymbols globalTable) exportSpecs)
2929
3030exportSpecSymbols :: Global. Table -> ExportSpec l -> [Symbol ]
3131exportSpecSymbols globalTable exportSpec =
@@ -70,7 +70,7 @@ annotateExportSpec globalTable exportSpec =
7070 [] -> scopeError (ENotInScope qn) exportSpec
7171 [symbol] ->
7272 let
73- subSymbols = nub (do
73+ subSymbols = nubSymbols (do
7474 subSymbol <- concat (Map. elems globalTable)
7575 Just subSymbolParentName <- return $ symbolParent subSymbol
7676 guard (subSymbolParentName == symbolName symbol)
@@ -109,3 +109,11 @@ annotateExportSpec globalTable exportSpec =
109109 (UnQual _ _, symbols) <- Map. toList globalTable
110110 symbols)
111111
112+
113+ nubSymbols :: [Symbol ] -> [Symbol ]
114+ nubSymbols = loop Set. empty where
115+ loop _ [] = []
116+ loop a (b : c) = if Set. member b a
117+ then loop a c
118+ else b : loop (Set. insert b a) c
119+
0 commit comments