git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Rename "ImportType" so semantically it works for exports too
a705217Gary Burgess
src/Language/PureScript/Declarations.hs+9−9
@@ -66,21 +66,21 @@ data ForeignImportType
66 | TypeClassAccessorImport deriving (Show, Eq, D.Data, D.Typeable)
66 | TypeClassAccessorImport deriving (Show, Eq, D.Data, D.Typeable)
67
67
68-- |
68-- |
69−-- An item in a list of explicit imports
69+-- An item in a list of explicit imports or exports
70--
70--
71−data ImportType
71+data DeclarationRef
72 -- |
72 -- |
73− -- A type constructor import
73+ -- A type constructor with data constructors
74 --
74 --
75− = TypeImport ProperName (Maybe [ProperName])
75+ = TypeRef ProperName (Maybe [ProperName])
76 -- |
76 -- |
77− -- A declaration import
77+ -- A value
78 --
78 --
79− | NameImport Ident
79+ | ValueRef Ident
80 -- |
80 -- |
81− -- A type class import
81+ -- A type class
82 --
82 --
83− | TypeClassImport ProperName
83+ | TypeClassRef ProperName
84 deriving (Show, D.Data, D.Typeable)
84 deriving (Show, D.Data, D.Typeable)
85
85
86-- |
86-- |
@@ -126,7 +126,7 @@ data Declaration
126 -- |
126 -- |
127 -- A module import (module name, optional set of identifiers to import)
127 -- A module import (module name, optional set of identifiers to import)
128 --
128 --
129− | ImportDeclaration ModuleName (Maybe [ImportType])
129+ | ImportDeclaration ModuleName (Maybe [DeclarationRef])
130 -- |
130 -- |
131 -- A type class declaration (name, argument, member declarations)
131 -- A type class declaration (name, argument, member declarations)
132 --
132 --
src/Language/PureScript/Parser/Declarations.hs+4−4
@@ -88,14 +88,14 @@ parseImportDeclaration = do
88 reserved "import"
88 reserved "import"
89 indented
89 indented
90 moduleName' <- moduleName
90 moduleName' <- moduleName
91− idents <- P.optionMaybe $ parens $ commaSep1 parseExplicitImport
91+ idents <- P.optionMaybe $ parens $ commaSep1 parseDeclarationRef
92 return $ ImportDeclaration moduleName' idents
92 return $ ImportDeclaration moduleName' idents
93
93
94−parseExplicitImport :: P.Parsec String ParseState ImportType
94+parseDeclarationRef :: P.Parsec String ParseState DeclarationRef
95−parseExplicitImport = NameImport <$> parseIdent
95+parseDeclarationRef = ValueRef <$> parseIdent
96 <|> do name <- properName
96 <|> do name <- properName
97 dctors <- P.optionMaybe $ parens (Just <$> commaSep1 properName <|> lexeme (P.string "..") *> pure Nothing)
97 dctors <- P.optionMaybe $ parens (Just <$> commaSep1 properName <|> lexeme (P.string "..") *> pure Nothing)
98− return $ maybe (TypeClassImport name) (TypeImport name) dctors
98+ return $ maybe (TypeClassRef name) (TypeRef name) dctors
99
99
100parseTypeClassDeclaration :: P.Parsec String ParseState Declaration
100parseTypeClassDeclaration :: P.Parsec String ParseState Declaration
101parseTypeClassDeclaration = do
101parseTypeClassDeclaration = do
src/Language/PureScript/Sugar/Names.hs+8−8
@@ -211,7 +211,7 @@ findExports = foldM addModule M.empty
211-- |
211-- |
212-- Type representing a set of declarations being explicitly imported from a module
212-- Type representing a set of declarations being explicitly imported from a module
213--
213--
214−type ExplicitImports = [ImportType]
214+type ExplicitImports = [DeclarationRef]
215
215
216-- |
216-- |
217-- Finds the imports within a module, mapping the imported module name to an optional set of
217-- Finds the imports within a module, mapping the imported module name to an optional set of
@@ -249,24 +249,24 @@ resolveImport currentModule importModule exp imp i = case i of
249 -- Import everything from a module
249 -- Import everything from a module
250 importAll :: ImportEnvironment -> Either String ImportEnvironment
250 importAll :: ImportEnvironment -> Either String ImportEnvironment
251 importAll imp = do
251 importAll imp = do
252− imp' <- foldM (\m (name, dctors) -> importExplicit m (TypeImport name (Just dctors))) imp (S.toList $ exportedTypes exp)
252+ imp' <- foldM (\m (name, dctors) -> importExplicit m (TypeRef name (Just dctors))) imp (S.toList $ exportedTypes exp)
253− imp'' <- foldM (\m name -> importExplicit m (NameImport name)) imp' (S.toList $ exportedValues exp)
253+ imp'' <- foldM (\m name -> importExplicit m (ValueRef name)) imp' (S.toList $ exportedValues exp)
254− foldM (\m name -> importExplicit m (TypeClassImport name)) imp'' (S.toList $ exportedTypeClasses exp)
254+ foldM (\m name -> importExplicit m (TypeClassRef name)) imp'' (S.toList $ exportedTypeClasses exp)
255
255
256 -- Import something explicitly
256 -- Import something explicitly
257− importExplicit :: ImportEnvironment -> ImportType -> Either String ImportEnvironment
257+ importExplicit :: ImportEnvironment -> DeclarationRef -> Either String ImportEnvironment
258− importExplicit imp (NameImport name) = do
258+ importExplicit imp (ValueRef name) = do
259 checkImportExists "value" values name
259 checkImportExists "value" values name
260 values' <- updateImports (importedValues imp) name
260 values' <- updateImports (importedValues imp) name
261 return $ imp { importedValues = values' }
261 return $ imp { importedValues = values' }
262− importExplicit imp (TypeImport name dctors) = do
262+ importExplicit imp (TypeRef name dctors) = do
263 checkImportExists "type" types name
263 checkImportExists "type" types name
264 types' <- updateImports (importedTypes imp) name
264 types' <- updateImports (importedTypes imp) name
265 let allDctors = allExportedDataConstructors name
265 let allDctors = allExportedDataConstructors name
266 dctors' <- maybe (return allDctors) (mapM $ checkDctorExists allDctors) dctors
266 dctors' <- maybe (return allDctors) (mapM $ checkDctorExists allDctors) dctors
267 dctors'' <- foldM updateImports (importedDataConstructors imp) dctors'
267 dctors'' <- foldM updateImports (importedDataConstructors imp) dctors'
268 return $ imp { importedTypes = types', importedDataConstructors = dctors'' }
268 return $ imp { importedTypes = types', importedDataConstructors = dctors'' }
269− importExplicit imp (TypeClassImport name) = do
269+ importExplicit imp (TypeClassRef name) = do
270 checkImportExists "type class" classes name
270 checkImportExists "type class" classes name
271 typeClasses' <- updateImports (importedTypeClasses imp) name
271 typeClasses' <- updateImports (importedTypeClasses imp) name
272 return $ imp { importedTypeClasses = typeClasses' }
272 return $ imp { importedTypeClasses = typeClasses' }