git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Remove unnecessary elaborateImports from Names
commite9b676f852068b58944006c720b741fa7905697e authorGary Burgess <gary.burgess@gmail.com> dateTue 24 Nov 2015, 14:37 (11 years ago) parentd58c0da
1 file changed+4−21
src/Language/PureScript/Sugar/Names.hs+4−21
src/Language/PureScript/Sugar/Names.hs+4−21
@@ -107,7 +107,7 @@ desugarImports externs modules = do
107107 let (_, imps, exps) = fromMaybe (internalError "Module is missing in renameInModule'") $ M.lookup mn env
108108 (m', used) <- flip runStateT M.empty $ renameInModule env imps (elaborateExports exps m)
109109 findUnusedImports m env used
110− return $ elaborateImports imps m'
110+ return m'
111111
112112-- |
113113-- Make all exports for a module explicit. This may still effect modules that
@@ -127,23 +127,6 @@ elaborateExports exps (Module ss coms mn decls refs) =
127127 my :: (Exports -> [(a, ModuleName)]) -> [a]
128128 my f = fst `map` filter ((== mn) . snd) (f exps)
129129
130−-- |
131−-- Add `import X ()` for any modules where there are only fully qualified references to members.
132−-- This ensures transitive instances are included when using a member from a module.
133−--
134−elaborateImports :: Imports -> Module -> Module
135−elaborateImports imps (Module ss coms mn decls exps) = Module ss coms mn decls' exps
136− where
137− decls' :: [Declaration]
138− decls' =
139− let (f, _, _, _, _) = everythingOnValues (++) (const []) fqValues (const []) (const []) (const [])
140− in mkImport `map` nub (f `concatMap` decls) ++ decls
141− fqValues :: Expr -> [ModuleName]
142− fqValues (Var (Qualified (Just mn') _)) | mn' `notElem` importedModules imps = [mn']
143− fqValues _ = []
144− mkImport :: ModuleName -> Declaration
145− mkImport mn' = ImportDeclaration mn' (Explicit []) Nothing False
146−
147130-- |
148131-- Replaces all local names with qualified names within a module and checks that all existing
149132-- qualified names are valid.
@@ -171,7 +154,7 @@ renameInModule env imports (Module ss coms mn decls exps) =
171154 updateDecl (pos, bound) (ExternDeclaration name ty) =
172155 (,) (pos, name : bound) <$> (ExternDeclaration name <$> updateTypesEverywhere pos ty)
173156 updateDecl s d = return (s, d)
174− --
157+
175158 updateValue :: (Maybe SourceSpan, [Ident]) -> Expr -> m ((Maybe SourceSpan, [Ident]), Expr)
176159 updateValue (_, bound) v@(PositionedValue pos' _ _) =
177160 return ((Just pos', bound), v)
@@ -192,7 +175,7 @@ renameInModule env imports (Module ss coms mn decls exps) =
192175 updateValue s@(pos, _) (TypedValue check val ty) =
193176 (,) s <$> (TypedValue check val <$> updateTypesEverywhere pos ty)
194177 updateValue s v = return (s, v)
195− --
178+
196179 updateBinder :: (Maybe SourceSpan, [Ident]) -> Binder -> m ((Maybe SourceSpan, [Ident]), Binder)
197180 updateBinder (_, bound) v@(PositionedBinder pos _ _) =
198181 return ((Just pos, bound), v)
@@ -204,7 +187,7 @@ renameInModule env imports (Module ss coms mn decls exps) =
204187 return (s', TypedBinder t' b')
205188 updateBinder s v =
206189 return (s, v)
207− --
190+
208191 updateCase :: (Maybe SourceSpan, [Ident]) -> CaseAlternative -> m ((Maybe SourceSpan, [Ident]), CaseAlternative)
209192 updateCase (pos, bound) c@(CaseAlternative bs _) =
210193 return ((pos, concatMap binderNames bs ++ bound), c)