git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Improve names for ImportDeclarationType constructors
2bfb486Harry Garrood
psci/Main.hs+3−3
@@ -113,7 +113,7 @@ updateLets ds st = st { psciLetBindings = psciLetBindings st ++ ds }
113-- Load the necessary modules.
113-- Load the necessary modules.
114--
114--
115defaultImports :: [C.ImportedModule]
115defaultImports :: [C.ImportedModule]
116−defaultImports = [(P.ModuleName [P.ProperName "Prelude"], D.Unqualified, Nothing)]
116+defaultImports = [(P.ModuleName [P.ProperName "Prelude"], D.Implicit, Nothing)]
117
117
118-- |
118-- |
119-- Locates the node executable.
119-- Locates the node executable.
@@ -476,8 +476,8 @@ handleShowImportedModules = do
476 Just mn' -> "qualified " ++ N.runModuleName mn ++ " as " ++ N.runModuleName mn'
476 Just mn' -> "qualified " ++ N.runModuleName mn ++ " as " ++ N.runModuleName mn'
477 Nothing -> N.runModuleName mn ++ " " ++ showDeclType declType
477 Nothing -> N.runModuleName mn ++ " " ++ showDeclType declType
478
478
479− showDeclType D.Unqualified = ""
479+ showDeclType D.Implicit = ""
480− showDeclType (D.Qualifying refs) = refsList refs
480+ showDeclType (D.Explicit refs) = refsList refs
481 showDeclType (D.Hiding refs) = "hiding " ++ refsList refs
481 showDeclType (D.Hiding refs) = "hiding " ++ refsList refs
482 refsList refs = "(" ++ commaList (map showRef refs) ++ ")"
482 refsList refs = "(" ++ commaList (map showRef refs) ++ ")"
483
483
src/Language/PureScript.hs+1−1
@@ -257,7 +257,7 @@ reverseDependencies g = combine [ (dep, mn) | (mn, deps) <- g, dep <- deps ]
257addDefaultImport :: ModuleName -> Module -> Module
257addDefaultImport :: ModuleName -> Module -> Module
258addDefaultImport toImport m@(Module coms mn decls exps) =
258addDefaultImport toImport m@(Module coms mn decls exps) =
259 if isExistingImport `any` decls || mn == toImport then m
259 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
261 where
261 where
262 isExistingImport (ImportDeclaration mn' _ _) | mn' == toImport = True
262 isExistingImport (ImportDeclaration mn' _ _) | mn' == toImport = True
263 isExistingImport (PositionedDeclaration _ _ d) = isExistingImport d
263 isExistingImport (PositionedDeclaration _ _ d) = isExistingImport d
src/Language/PureScript/AST/Declarations.hs+5−5
@@ -127,15 +127,15 @@ instance Eq DeclarationRef where
127--
127--
128data ImportDeclarationType
128data ImportDeclarationType
129 -- |
129 -- |
130− -- Unqualified import
130+ -- An import with no explicit list: `import M`
131 --
131 --
132− = Unqualified
132+ = Implicit
133 -- |
133 -- |
134− -- Qualified import with a list of references to import
134+ -- An import with an explicit list of references to import: `import M (foo)`
135 --
135 --
136− | Qualifying [DeclarationRef]
136+ | Explicit [DeclarationRef]
137 -- |
137 -- |
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)`
139 --
139 --
140 | Hiding [DeclarationRef]
140 | Hiding [DeclarationRef]
141 deriving (Show, D.Data, D.Typeable)
141 deriving (Show, D.Data, D.Typeable)
src/Language/PureScript/Parser/Declarations.hs+3−3
@@ -165,19 +165,19 @@ parseImportDeclaration' = do
165 declType <- importDeclarationType Hiding
165 declType <- importDeclarationType Hiding
166 return (mn, declType, Nothing)
166 return (mn, declType, Nothing)
167 stdImportQualifying mn = do
167 stdImportQualifying mn = do
168− declType <- importDeclarationType Qualifying
168+ declType <- importDeclarationType Explicit
169 return (mn, declType, Nothing)
169 return (mn, declType, Nothing)
170 qualImport = do
170 qualImport = do
171 reserved "qualified"
171 reserved "qualified"
172 indented
172 indented
173 moduleName' <- moduleName
173 moduleName' <- moduleName
174− declType <- importDeclarationType Qualifying
174+ declType <- importDeclarationType Explicit
175 reserved "as"
175 reserved "as"
176 asQ <- moduleName
176 asQ <- moduleName
177 return (moduleName', declType, Just asQ)
177 return (moduleName', declType, Just asQ)
178 importDeclarationType expectedType = do
178 importDeclarationType expectedType = do
179 idents <- P.optionMaybe $ indented *> (parens $ commaSep parseDeclarationRef)
179 idents <- P.optionMaybe $ indented *> (parens $ commaSep parseDeclarationRef)
180− return $ fromMaybe Unqualified (expectedType <$> idents)
180+ return $ fromMaybe Implicit (expectedType <$> idents)
181
181
182
182
183parseDeclarationRef :: TokenParser DeclarationRef
183parseDeclarationRef :: 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
199 fqValues (Var (Qualified (Just mn') _)) = [mn']
199 fqValues (Var (Qualified (Just mn') _)) = [mn']
200 fqValues _ = []
200 fqValues _ = []
201 mkImport :: ModuleName -> Declaration
201 mkImport :: ModuleName -> Declaration
202− mkImport mn' = ImportDeclaration mn' (Qualifying []) Nothing
202+ mkImport mn' = ImportDeclaration mn' (Explicit []) Nothing
203
203
204-- |
204-- |
205-- Replaces all local names with qualified names within a module and checks that all existing
205-- Replaces all local names with qualified names within a module and checks that all existing
@@ -417,7 +417,7 @@ resolveImports env (Module _ currentModule decls _) =
417 -- module (where Nothing indicates everything is to be imported), and optionally a qualified name
417 -- module (where Nothing indicates everything is to be imported), and optionally a qualified name
418 -- for the module
418 -- for the module
419 scope :: M.Map ModuleName (Maybe SourceSpan, ImportDeclarationType, Maybe ModuleName)
419 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)
421
421
422 resolveImport' :: ImportEnvironment -> (ModuleName, (Maybe SourceSpan, ImportDeclarationType, Maybe ModuleName)) -> m ImportEnvironment
422 resolveImport' :: ImportEnvironment -> (ModuleName, (Maybe SourceSpan, ImportDeclarationType, Maybe ModuleName)) -> m ImportEnvironment
423 resolveImport' imp (mn, (pos, typ, impQual)) = do
423 resolveImport' imp (mn, (pos, typ, impQual)) = do
@@ -437,8 +437,8 @@ resolveImport currentModule importModule exps imps impQual =
437 where
437 where
438
438
439 resolveByType :: ImportDeclarationType -> m ImportEnvironment
439 resolveByType :: ImportDeclarationType -> m ImportEnvironment
440− resolveByType Unqualified = importAll importExplicit
440+ resolveByType Implicit = importAll importExplicit
441− resolveByType (Qualifying explImports) = (checkedRefs >=> foldM importExplicit imps) explImports
441+ resolveByType (Explicit explImports) = (checkedRefs >=> foldM importExplicit imps) explImports
442 resolveByType (Hiding hiddenImports) = do
442 resolveByType (Hiding hiddenImports) = do
443 hiddenImports' <- checkedRefs hiddenImports
443 hiddenImports' <- checkedRefs hiddenImports
444 importAll (importNonHidden hiddenImports')
444 importAll (importNonHidden hiddenImports')