git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Rename "ImportType" so semantically it works for exports too
commita70521754010090adc7b9b44968cc3197ba9c3ae authorGary Burgess <gary.burgess@gmail.com> dateWed 5 Mar 2014, 09:23 (13 years ago) parentf553355
3 files changed+21−21
src/Language/PureScript/Declarations.hs+9−9 src/Language/PureScript/Parser/Declarations.hs+4−4 src/Language/PureScript/Sugar/Names.hs+8−8
src/Language/PureScript/Declarations.hs+9−9
@@ -66,21 +66,21 @@ data ForeignImportType
6666 | TypeClassAccessorImport deriving (Show, Eq, D.Data, D.Typeable)
6767
6868-- |
69−-- An item in a list of explicit imports
69+-- An item in a list of explicit imports or exports
7070--
71−data ImportType
71+data DeclarationRef
7272 -- |
73− -- A type constructor import
73+ -- A type constructor with data constructors
7474 --
75− = TypeImport ProperName (Maybe [ProperName])
75+ = TypeRef ProperName (Maybe [ProperName])
7676 -- |
77− -- A declaration import
77+ -- A value
7878 --
79− | NameImport Ident
79+ | ValueRef Ident
8080 -- |
81− -- A type class import
81+ -- A type class
8282 --
83− | TypeClassImport ProperName
83+ | TypeClassRef ProperName
8484 deriving (Show, D.Data, D.Typeable)
8585
8686-- |
@@ -126,7 +126,7 @@ data Declaration
126126 -- |
127127 -- A module import (module name, optional set of identifiers to import)
128128 --
129− | ImportDeclaration ModuleName (Maybe [ImportType])
129+ | ImportDeclaration ModuleName (Maybe [DeclarationRef])
130130 -- |
131131 -- A type class declaration (name, argument, member declarations)
132132 --
src/Language/PureScript/Parser/Declarations.hs+4−4
@@ -88,14 +88,14 @@ parseImportDeclaration = do
8888 reserved "import"
8989 indented
9090 moduleName' <- moduleName
91− idents <- P.optionMaybe $ parens $ commaSep1 parseExplicitImport
91+ idents <- P.optionMaybe $ parens $ commaSep1 parseDeclarationRef
9292 return $ ImportDeclaration moduleName' idents
9393
94−parseExplicitImport :: P.Parsec String ParseState ImportType
95−parseExplicitImport = NameImport <$> parseIdent
94+parseDeclarationRef :: P.Parsec String ParseState DeclarationRef
95+parseDeclarationRef = ValueRef <$> parseIdent
9696 <|> do name <- properName
9797 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
9999
100100parseTypeClassDeclaration :: P.Parsec String ParseState Declaration
101101parseTypeClassDeclaration = do
src/Language/PureScript/Sugar/Names.hs+8−8
@@ -211,7 +211,7 @@ findExports = foldM addModule M.empty
211211-- |
212212-- Type representing a set of declarations being explicitly imported from a module
213213--
214−type ExplicitImports = [ImportType]
214+type ExplicitImports = [DeclarationRef]
215215
216216-- |
217217-- 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
249249 -- Import everything from a module
250250 importAll :: ImportEnvironment -> Either String ImportEnvironment
251251 importAll imp = do
252− imp' <- foldM (\m (name, dctors) -> importExplicit m (TypeImport name (Just dctors))) imp (S.toList $ exportedTypes exp)
253− imp'' <- foldM (\m name -> importExplicit m (NameImport name)) imp' (S.toList $ exportedValues exp)
254− foldM (\m name -> importExplicit m (TypeClassImport name)) imp'' (S.toList $ exportedTypeClasses 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 (ValueRef name)) imp' (S.toList $ exportedValues exp)
254+ foldM (\m name -> importExplicit m (TypeClassRef name)) imp'' (S.toList $ exportedTypeClasses exp)
255255
256256 -- Import something explicitly
257− importExplicit :: ImportEnvironment -> ImportType -> Either String ImportEnvironment
258− importExplicit imp (NameImport name) = do
257+ importExplicit :: ImportEnvironment -> DeclarationRef -> Either String ImportEnvironment
258+ importExplicit imp (ValueRef name) = do
259259 checkImportExists "value" values name
260260 values' <- updateImports (importedValues imp) name
261261 return $ imp { importedValues = values' }
262− importExplicit imp (TypeImport name dctors) = do
262+ importExplicit imp (TypeRef name dctors) = do
263263 checkImportExists "type" types name
264264 types' <- updateImports (importedTypes imp) name
265265 let allDctors = allExportedDataConstructors name
266266 dctors' <- maybe (return allDctors) (mapM $ checkDctorExists allDctors) dctors
267267 dctors'' <- foldM updateImports (importedDataConstructors imp) dctors'
268268 return $ imp { importedTypes = types', importedDataConstructors = dctors'' }
269− importExplicit imp (TypeClassImport name) = do
269+ importExplicit imp (TypeClassRef name) = do
270270 checkImportExists "type class" classes name
271271 typeClasses' <- updateImports (importedTypeClasses imp) name
272272 return $ imp { importedTypeClasses = typeClasses' }