git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Improve names for ImportDeclarationType constructors
commit2bfb4862720551e4e9600006a7fc49e95032c112 authorHarry Garrood <harry@garrood.me> dateSat 14 Mar 2015, 17:46 (12 years ago) parent9a72e09
5 files changed+16−16
psci/Main.hs+3−3 src/Language/PureScript.hs+1−1 src/Language/PureScript/AST/Declarations.hs+5−5 src/Language/PureScript/Parser/Declarations.hs+3−3 src/Language/PureScript/Sugar/Names.hs+4−4
psci/Main.hs+3−3
@@ -113,7 +113,7 @@ updateLets ds st = st { psciLetBindings = psciLetBindings st ++ ds }
113113-- Load the necessary modules.
114114--
115115defaultImports :: [C.ImportedModule]
116−defaultImports = [(P.ModuleName [P.ProperName "Prelude"], D.Unqualified, Nothing)]
116+defaultImports = [(P.ModuleName [P.ProperName "Prelude"], D.Implicit, Nothing)]
117117
118118-- |
119119-- Locates the node executable.
@@ -476,8 +476,8 @@ handleShowImportedModules = do
476476 Just mn' -> "qualified " ++ N.runModuleName mn ++ " as " ++ N.runModuleName mn'
477477 Nothing -> N.runModuleName mn ++ " " ++ showDeclType declType
478478
479− showDeclType D.Unqualified = ""
480− showDeclType (D.Qualifying refs) = refsList refs
479+ showDeclType D.Implicit = ""
480+ showDeclType (D.Explicit refs) = refsList refs
481481 showDeclType (D.Hiding refs) = "hiding " ++ refsList refs
482482 refsList refs = "(" ++ commaList (map showRef refs) ++ ")"
483483
src/Language/PureScript.hs+1−1
@@ -257,7 +257,7 @@ reverseDependencies g = combine [ (dep, mn) | (mn, deps) <- g, dep <- deps ]
257257addDefaultImport :: ModuleName -> Module -> Module
258258addDefaultImport toImport m@(Module coms mn decls exps) =
259259 if isExistingImport `any` decls || mn == toImport then m
260− else Module coms mn (ImportDeclaration toImport Unqualified Nothing : decls) exps
260+ else Module coms mn (ImportDeclaration toImport Implicit Nothing : decls) exps
261261 where
262262 isExistingImport (ImportDeclaration mn' _ _) | mn' == toImport = True
263263 isExistingImport (PositionedDeclaration _ _ d) = isExistingImport d
src/Language/PureScript/AST/Declarations.hs+5−5
@@ -127,15 +127,15 @@ instance Eq DeclarationRef where
127127--
128128data ImportDeclarationType
129129 -- |
130− -- Unqualified import
130+ -- An import with no explicit list: `import M`
131131 --
132− = Unqualified
132+ = Implicit
133133 -- |
134− -- Qualified import with a list of references to import
134+ -- An import with an explicit list of references to import: `import M (foo)`
135135 --
136− | Qualifying [DeclarationRef]
136+ | Explicit [DeclarationRef]
137137 -- |
138− -- Import with hiding clause with a list of references to hide
138+ -- An import with a list of references to hide: `import M hiding (foo)`
139139 --
140140 | Hiding [DeclarationRef]
141141 deriving (Show, D.Data, D.Typeable)
src/Language/PureScript/Parser/Declarations.hs+3−3
@@ -165,19 +165,19 @@ parseImportDeclaration' = do
165165 declType <- importDeclarationType Hiding
166166 return (mn, declType, Nothing)
167167 stdImportQualifying mn = do
168− declType <- importDeclarationType Qualifying
168+ declType <- importDeclarationType Explicit
169169 return (mn, declType, Nothing)
170170 qualImport = do
171171 reserved "qualified"
172172 indented
173173 moduleName' <- moduleName
174− declType <- importDeclarationType Qualifying
174+ declType <- importDeclarationType Explicit
175175 reserved "as"
176176 asQ <- moduleName
177177 return (moduleName', declType, Just asQ)
178178 importDeclarationType expectedType = do
179179 idents <- P.optionMaybe $ indented *> (parens $ commaSep parseDeclarationRef)
180− return $ fromMaybe Unqualified (expectedType <$> idents)
180+ return $ fromMaybe Implicit (expectedType <$> idents)
181181
182182
183183parseDeclarationRef :: TokenParser DeclarationRef
src/Language/PureScript/Sugar/Names.hs+4−4
@@ -199,7 +199,7 @@ elaborateImports (Module coms mn decls exps) = Module coms mn decls' exps
199199 fqValues (Var (Qualified (Just mn') _)) = [mn']
200200 fqValues _ = []
201201 mkImport :: ModuleName -> Declaration
202− mkImport mn' = ImportDeclaration mn' (Qualifying []) Nothing
202+ mkImport mn' = ImportDeclaration mn' (Explicit []) Nothing
203203
204204-- |
205205-- Replaces all local names with qualified names within a module and checks that all existing
@@ -417,7 +417,7 @@ resolveImports env (Module _ currentModule decls _) =
417417 -- module (where Nothing indicates everything is to be imported), and optionally a qualified name
418418 -- for the module
419419 scope :: M.Map ModuleName (Maybe SourceSpan, ImportDeclarationType, Maybe ModuleName)
420− scope = M.insert currentModule (Nothing, Unqualified, Nothing) (findImports decls)
420+ scope = M.insert currentModule (Nothing, Implicit, Nothing) (findImports decls)
421421
422422 resolveImport' :: ImportEnvironment -> (ModuleName, (Maybe SourceSpan, ImportDeclarationType, Maybe ModuleName)) -> m ImportEnvironment
423423 resolveImport' imp (mn, (pos, typ, impQual)) = do
@@ -437,8 +437,8 @@ resolveImport currentModule importModule exps imps impQual =
437437 where
438438
439439 resolveByType :: ImportDeclarationType -> m ImportEnvironment
440− resolveByType Unqualified = importAll importExplicit
441− resolveByType (Qualifying explImports) = (checkedRefs >=> foldM importExplicit imps) explImports
440+ resolveByType Implicit = importAll importExplicit
441+ resolveByType (Explicit explImports) = (checkedRefs >=> foldM importExplicit imps) explImports
442442 resolveByType (Hiding hiddenImports) = do
443443 hiddenImports' <- checkedRefs hiddenImports
444444 importAll (importNonHidden hiddenImports')