Skip to content

Commit 2bfb486

Browse files
committed
Improve names for ImportDeclarationType constructors
1 parent 9a72e09 commit 2bfb486

File tree

5 files changed

+16
-16
lines changed

5 files changed

+16
-16
lines changed

psci/Main.hs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ updateLets ds st = st { psciLetBindings = psciLetBindings st ++ ds }
113113
-- Load the necessary modules.
114114
--
115115
defaultImports :: [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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ reverseDependencies g = combine [ (dep, mn) | (mn, deps) <- g, dep <- deps ]
257257
addDefaultImport :: ModuleName -> Module -> Module
258258
addDefaultImport 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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -127,15 +127,15 @@ instance Eq DeclarationRef where
127127
--
128128
data 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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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

183183
parseDeclarationRef :: TokenParser DeclarationRef

src/Language/PureScript/Sugar/Names.hs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -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')

0 commit comments

Comments
 (0)