git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Remove qualified keyword, merge #1997
commit7fcebc8f37f3b236958aa3ae23d78d0938901173 authorPhil Freeman <paf31@cantab.net> dateSat 30 Apr 2016, 14:34 (11 years ago) parentb34f5f9
21 files changed+39−68
examples/failing/OverlappingReExport.purs+1−1 examples/passing/AutoPrelude2.purs+1−1 examples/passing/ModuleExportQualified.purs+1−1 examples/passing/OptionalQualified.purs+1−2 examples/passing/QualifiedQualifiedImports.purs+1−1 examples/passing/ReExportQualified.purs+1−1 psci/PSCi/Completion.hs+2−5 psci/PSCi/Module.hs+1−1 psci/PSCi/Parser.hs+1−1 src/Language/PureScript/AST/Declarations.hs+3−4 src/Language/PureScript/CoreFn/Desugar.hs+1−1 src/Language/PureScript/Errors.hs−11 src/Language/PureScript/Externs.hs+1−1 src/Language/PureScript/Ide/Imports.hs+4−5 src/Language/PureScript/Ide/Rebuild.hs+1−1 src/Language/PureScript/Ide/SourceFile.hs+3−3 src/Language/PureScript/Linter/Imports.hs+2−2 src/Language/PureScript/ModuleDependencies.hs+2−2 src/Language/PureScript/Parser/Declarations.hs+7−16 src/Language/PureScript/Sugar/Names/Imports.hs+4−5 tests/TestPsci.hs+1−3
examples/failing/OverlappingReExport.purs+1−1
@@ -7,4 +7,4 @@ module B where
77
88module C (module A, module M2) where
99 import A
10− import qualified B as M2
10+ import B as M2
examples/passing/AutoPrelude2.purs+1−1
@@ -1,7 +1,7 @@
11module Main where
22
33import Prelude
4−import qualified Prelude as P
4+import Prelude as P
55import Control.Monad.Eff.Console
66
77f :: forall a. a -> a
examples/passing/ModuleExportQualified.purs+1−1
@@ -3,7 +3,7 @@ module A (module Prelude) where
33
44module Main where
55 import Control.Monad.Eff.Console
6− import qualified A as B
6+ import A as B
77
88 main = do
99 print (B.show 1.0)
examples/passing/OptionalQualified.purs+1−2
@@ -1,7 +1,6 @@
11module Main where
22
3−-- qualified import with the "qualified" keyword
4−import qualified Prelude as P
3+import Prelude as P
54
65-- qualified import without the "qualified" keyword
76import Control.Monad.Eff.Console as Console
examples/passing/QualifiedQualifiedImports.purs+1−1
@@ -1,6 +1,6 @@
11module Main where
22
33-- qualified import with qualified imported names
4−import qualified Control.Monad.Eff.Console (log) as Console
4+import Control.Monad.Eff.Console (log) as Console
55
66main = Console.log "Success!"
examples/passing/ReExportQualified.purs+1−1
@@ -6,7 +6,7 @@ module B where
66
77module C (module A, module M2) where
88 import A
9− import qualified B as M2
9+ import B as M2
1010
1111module Main where
1212
psci/PSCi/Completion.hs+2−5
@@ -7,7 +7,6 @@ import Prelude.Compat
77
88import Data.Maybe (mapMaybe)
99import Data.List (nub, nubBy, sortBy, isPrefixOf, stripPrefix)
10−import Data.Char (isUpper)
1110import Data.Function (on)
1211
1312import Control.Arrow (second)
@@ -87,10 +86,8 @@ directiveArg _ Kind = [CtxType]
8786completeImport :: [String] -> String -> [CompletionContext]
8887completeImport ws w' =
8988 case (ws, w') of
90− (["import"], w) | headSatisfies isUpper w -> [CtxModule]
91− (["import"], _) -> [CtxModule, CtxFixed "qualified"]
92− (["import", "qualified"], _) -> [CtxModule]
93− _ -> []
89+ (["import"], _) -> [CtxModule]
90+ _ -> []
9491
9592headSatisfies :: (a -> Bool) -> [a] -> Bool
9693headSatisfies p str =
psci/PSCi/Module.hs+1−1
@@ -98,7 +98,7 @@ createTemporaryModuleForImports PSCiState{psciImportedModules = imports} =
9898 P.Module (P.internalModuleSourceSpan "<internal>") [] moduleName (importDecl `map` imports) Nothing
9999
100100importDecl :: ImportedModule -> P.Declaration
101−importDecl (mn, declType, asQ) = P.ImportDeclaration mn declType asQ False
101+importDecl (mn, declType, asQ) = P.ImportDeclaration mn declType asQ
102102
103103indexFile :: FilePath
104104indexFile = ".psci_modules" ++ pathSeparator : "index.js"
psci/PSCi/Parser.hs+1−1
@@ -107,7 +107,7 @@ psciLet = Decls <$> (P.reserved "let" *> P.indented *> manyDecls)
107107-- :show import works, for example.
108108psciImport :: P.TokenParser Command
109109psciImport = do
110− (mn, declType, asQ, _) <- P.parseImportDeclaration'
110+ (mn, declType, asQ) <- P.parseImportDeclaration'
111111 return $ Import (mn, declType, asQ)
112112
113113-- | Any other declaration that we don't need a 'special case' parser for
src/Language/PureScript/AST/Declarations.hs+3−4
@@ -47,9 +47,9 @@ getModuleName (Module _ _ name _ _) = name
4747addDefaultImport :: ModuleName -> Module -> Module
4848addDefaultImport toImport m@(Module ss coms mn decls exps) =
4949 if isExistingImport `any` decls || mn == toImport then m
50− else Module ss coms mn (ImportDeclaration toImport Implicit Nothing False : decls) exps
50+ else Module ss coms mn (ImportDeclaration toImport Implicit Nothing : decls) exps
5151 where
52− isExistingImport (ImportDeclaration mn' _ _ _) | mn' == toImport = True
52+ isExistingImport (ImportDeclaration mn' _ _) | mn' == toImport = True
5353 isExistingImport (PositionedDeclaration _ _ d) = isExistingImport d
5454 isExistingImport _ = False
5555
@@ -198,9 +198,8 @@ data Declaration
198198 | FixityDeclaration Fixity String (Maybe (Qualified FixityAlias))
199199 -- |
200200 -- A module import (module name, qualified/unqualified/hiding, optional "qualified as" name)
201− -- TODO: also a boolean specifying whether the old `qualified` syntax was used, so a warning can be raised in desugaring (remove for 0.9)
202201 --
203− | ImportDeclaration ModuleName ImportDeclarationType (Maybe ModuleName) Bool
202+ | ImportDeclaration ModuleName ImportDeclarationType (Maybe ModuleName)
204203 -- |
205204 -- A type class declaration (name, argument, implies, member declarations)
206205 --
src/Language/PureScript/CoreFn/Desugar.hs+1−1
@@ -230,7 +230,7 @@ findQualModules decls =
230230-- Desugars import declarations from AST to CoreFn representation.
231231--
232232importToCoreFn :: A.Declaration -> Maybe (Ann, ModuleName)
233−importToCoreFn (A.ImportDeclaration name _ _ _) = Just (nullAnn, name)
233+importToCoreFn (A.ImportDeclaration name _ _) = Just (nullAnn, name)
234234importToCoreFn (A.PositionedDeclaration ss _ d) =
235235 ((,) (Just ss, [], Nothing, Nothing) . snd) <$> importToCoreFn d
236236importToCoreFn _ = Nothing
src/Language/PureScript/Errors.hs−11
@@ -142,7 +142,6 @@ data SimpleErrorMessage
142142 | UnusedDctorExplicitImport (ProperName 'TypeName) [ProperName 'ConstructorName]
143143 | DeprecatedOperatorDecl String
144144 | DeprecatedOperatorSection Expr (Either Expr Expr)
145− | DeprecatedQualifiedSyntax ModuleName ModuleName
146145 | DeprecatedClassImport ModuleName (ProperName 'ClassName)
147146 | DeprecatedClassExport (ProperName 'ClassName)
148147 | DuplicateSelectiveImport ModuleName
@@ -331,7 +330,6 @@ errorCode em = case unwrapErrorMessage em of
331330 UnusedDctorExplicitImport{} -> "UnusedDctorExplicitImport"
332331 DeprecatedOperatorDecl{} -> "DeprecatedOperatorDecl"
333332 DeprecatedOperatorSection{} -> "DeprecatedOperatorSection"
334− DeprecatedQualifiedSyntax{} -> "DeprecatedQualifiedSyntax"
335333 DeprecatedClassImport{} -> "DeprecatedClassImport"
336334 DeprecatedClassExport{} -> "DeprecatedClassExport"
337335 DuplicateSelectiveImport{} -> "DuplicateSelectiveImport"
@@ -463,8 +461,6 @@ errorSuggestion err = case err of
463461 UnusedImport{} -> emptySuggestion
464462 RedundantEmptyHidingImport{} -> emptySuggestion
465463 DuplicateImport{} -> emptySuggestion
466− DeprecatedQualifiedSyntax name qualName -> suggest $
467− "import " ++ runModuleName name ++ " as " ++ runModuleName qualName
468464 UnusedExplicitImport mn _ qual refs -> suggest $ importSuggestion mn refs qual
469465 ImplicitImport mn refs -> suggest $ importSuggestion mn refs Nothing
470466 ImplicitQualifiedImport mn asModule refs -> suggest $ importSuggestion mn refs (Just asModule)
@@ -951,13 +947,6 @@ prettyPrintSingleError full level showWiki e = flip evalState defaultUnknownMap
951947 renderOperator (PositionedValue _ _ ex) = renderOperator ex
952948 renderOperator (Var (Qualified _ (Op ident))) = line ident
953949 renderOperator other = Box.hcat Box.top [ line "`", prettyPrintValue valueDepth other, line "`" ]
954− renderSimpleErrorMessage (DeprecatedQualifiedSyntax name qualName) =
955− paras [ line "Import uses the deprecated 'qualified' syntax:"
956− , indent $ line $ "import qualified " ++ runModuleName name ++ " as " ++ runModuleName qualName
957− , line "Should instead use the form:"
958− , indent $ line $ "import " ++ runModuleName name ++ " as " ++ runModuleName qualName
959− , line "The deprecated syntax will be removed in PureScript 0.9."
960− ]
961950
962951 renderSimpleErrorMessage (DeprecatedClassImport mn name) =
963952 paras [ line $ "Class import from " ++ runModuleName mn ++ " uses deprecated syntax that omits the 'class' keyword:"
src/Language/PureScript/Externs.hs+1−1
@@ -165,7 +165,7 @@ moduleToExternsFile (Module _ _ mn ds (Just exps)) env = ExternsFile{..}
165165 fixityDecl _ = Nothing
166166
167167 importDecl :: Declaration -> Maybe ExternsImport
168− importDecl (ImportDeclaration m mt qmn _) = Just (ExternsImport m mt qmn)
168+ importDecl (ImportDeclaration m mt qmn) = Just (ExternsImport m mt qmn)
169169 importDecl (PositionedDeclaration _ _ d) = importDecl d
170170 importDecl _ = Nothing
171171
src/Language/PureScript/Ide/Imports.hs+4−5
@@ -95,9 +95,9 @@ parseImportsWithModuleName ls = do
9595 (P.Module _ _ mn decls _) <- moduleParse ls
9696 pure (mn, concatMap mkImport (unwrapPositioned <$> decls))
9797 where
98− mkImport (P.ImportDeclaration mn (P.Explicit refs) qual _) =
98+ mkImport (P.ImportDeclaration mn (P.Explicit refs) qual) =
9999 [Import mn (P.Explicit (unwrapPositionedRef <$> refs)) qual]
100− mkImport (P.ImportDeclaration mn it qual _) = [Import mn it qual]
100+ mkImport (P.ImportDeclaration mn it qual) = [Import mn it qual]
101101 mkImport _ = []
102102
103103sliceImportSection :: [Text] -> Either String (P.ModuleName, [Text], [Import], [Text])
@@ -348,8 +348,7 @@ parseImport :: Text -> Maybe Import
348348parseImport t =
349349 case P.lex "<psc-ide>" (T.unpack t)
350350 >>= P.runTokenParser "<psc-ide>" P.parseImportDeclaration' of
351− Right (mn, P.Explicit refs, mmn, _) ->
351+ Right (mn, P.Explicit refs, mmn) ->
352352 Just (Import mn (P.Explicit (unwrapPositionedRef <$> refs)) mmn)
353− Right (mn, idt, mmn, _) -> Just (Import mn idt mmn)
353+ Right (mn, idt, mmn) -> Just (Import mn idt mmn)
354354 Left _ -> Nothing
355−
src/Language/PureScript/Ide/Rebuild.hs+1−1
@@ -78,7 +78,7 @@ sortExterns m ex = do
7878 mkShallowModule P.ExternsFile{..} =
7979 P.Module undefined [] efModuleName (map mkImport efImports) Nothing
8080 mkImport (P.ExternsImport mn it iq) =
81− P.ImportDeclaration mn it iq False
81+ P.ImportDeclaration mn it iq
8282 getExtern mn = M.lookup mn ex
8383 -- Sort a list so its elements appear in the same order as in another list.
8484 inOrderOf :: (Ord a) => [a] -> [a] -> [a]
src/Language/PureScript/Ide/SourceFile.hs+3−3
@@ -68,14 +68,14 @@ getImportsForFile fp = do
6868 let imports = getImports module'
6969 pure (mkModuleImport . unwrapPositionedImport <$> imports)
7070 where
71− mkModuleImport (D.ImportDeclaration mn importType' qualifier _) =
71+ mkModuleImport (D.ImportDeclaration mn importType' qualifier) =
7272 ModuleImport
7373 (T.pack (N.runModuleName mn))
7474 importType'
7575 (T.pack . N.runModuleName <$> qualifier)
7676 mkModuleImport _ = error "Shouldn't have gotten anything but Imports here"
77− unwrapPositionedImport (D.ImportDeclaration mn importType' qualifier b) =
78− D.ImportDeclaration mn (unwrapImportType importType') qualifier b
77+ unwrapPositionedImport (D.ImportDeclaration mn importType' qualifier) =
78+ D.ImportDeclaration mn (unwrapImportType importType') qualifier
7979 unwrapPositionedImport x = x
8080 unwrapImportType (D.Explicit decls) = D.Explicit (map unwrapPositionedRef decls)
8181 unwrapImportType (D.Hiding decls) = D.Hiding (map unwrapPositionedRef decls)
src/Language/PureScript/Linter/Imports.hs+2−2
@@ -112,8 +112,8 @@ lintImports (Module _ _ mn mdecls mexports) env usedImps = do
112112 where
113113
114114 countOpenImports :: Declaration -> Int
115− countOpenImports (ImportDeclaration mn' Implicit Nothing _) | not (isPrim mn') = 1
116− countOpenImports (ImportDeclaration mn' (Hiding _) Nothing _) | not (isPrim mn') = 1
115+ countOpenImports (ImportDeclaration mn' Implicit Nothing) | not (isPrim mn') = 1
116+ countOpenImports (ImportDeclaration mn' (Hiding _) Nothing) | not (isPrim mn') = 1
117117 countOpenImports (PositionedDeclaration _ _ d) = countOpenImports d
118118 countOpenImports _ = 0
119119
src/Language/PureScript/ModuleDependencies.hs+2−2
@@ -47,7 +47,7 @@ sortModules ms = do
4747 -- Extract module names that have been brought into scope by an `as` import.
4848 extractQualAs :: Declaration -> [ModuleName]
4949 extractQualAs (PositionedDeclaration _ _ d) = extractQualAs d
50− extractQualAs (ImportDeclaration _ _ (Just am) _) = [am]
50+ extractQualAs (ImportDeclaration _ _ (Just am)) = [am]
5151 extractQualAs _ = []
5252
5353-- |
@@ -65,7 +65,7 @@ usedModules ams d =
6565 where
6666
6767 forDecls :: Declaration -> [ModuleName]
68− forDecls (ImportDeclaration mn _ _ _) =
68+ forDecls (ImportDeclaration mn _ _) =
6969 -- Regardless of whether an imported module is qualified we still need to
7070 -- take into account its import to build an accurate list of dependencies.
7171 [mn]
src/Language/PureScript/Parser/Declarations.hs+7−16
@@ -132,28 +132,19 @@ parseFixityDeclaration = do
132132
133133parseImportDeclaration :: TokenParser Declaration
134134parseImportDeclaration = do
135− (mn, declType, asQ, isOldSyntax) <- parseImportDeclaration'
136− return $ ImportDeclaration mn declType asQ isOldSyntax
135+ (mn, declType, asQ) <- parseImportDeclaration'
136+ return $ ImportDeclaration mn declType asQ
137137
138−parseImportDeclaration' :: TokenParser (ModuleName, ImportDeclarationType, Maybe ModuleName, Bool)
138+parseImportDeclaration' :: TokenParser (ModuleName, ImportDeclarationType, Maybe ModuleName)
139139parseImportDeclaration' = do
140140 reserved "import"
141141 indented
142− qualImport <|> stdImport
142+ moduleName' <- moduleName
143+ declType <- reserved "hiding" *> qualifyingList Hiding <|> qualifyingList Explicit
144+ qName <- P.optionMaybe qualifiedName
145+ return (moduleName', declType, qName)
143146 where
144− stdImport = do
145− moduleName' <- moduleName
146− declType <- reserved "hiding" *> qualifyingList Hiding <|> qualifyingList Explicit
147− qName <- P.optionMaybe qualifiedName
148− return (moduleName', declType, qName, False)
149147 qualifiedName = reserved "as" *> moduleName
150− qualImport = do
151− reserved "qualified"
152− indented
153− moduleName' <- moduleName
154− declType <- qualifyingList Explicit
155− qName <- qualifiedName
156− return (moduleName', declType, Just qName, True)
157148 qualifyingList expectedType = do
158149 declType <- P.optionMaybe (expectedType <$> (indented *> parens (commaSep parseDeclarationRef)))
159150 return $ fromMaybe Implicit declType
src/Language/PureScript/Sugar/Names/Imports.hs+4−5
@@ -15,7 +15,7 @@ import Prelude.Compat
1515import Data.Foldable (traverse_, for_)
1616import Data.Function (on)
1717import Data.List (find, sortBy, groupBy, (\\))
18−import Data.Maybe (fromMaybe, isNothing, fromJust)
18+import Data.Maybe (fromMaybe, isNothing)
1919import Data.Traversable (for)
2020
2121import Control.Arrow (first)
@@ -43,8 +43,7 @@ findImports
4343 -> m (M.Map ModuleName [(Maybe SourceSpan, ImportDeclarationType, Maybe ModuleName)])
4444findImports = foldM (go Nothing) M.empty
4545 where
46− go pos result (ImportDeclaration mn typ qual isOldSyntax) = do
47− when isOldSyntax . tell . errorMessage $ DeprecatedQualifiedSyntax mn (fromJust qual)
46+ go pos result (ImportDeclaration mn typ qual) = do
4847 let imp = (pos, typ, qual)
4948 return $ M.insert mn (maybe [imp] (imp :) (mn `M.lookup` result)) result
5049 go _ result (PositionedDeclaration pos _ d) = warnAndRethrowWithPosition pos $ go (Just pos) result d
@@ -137,13 +136,13 @@ resolveImports env (Module ss coms currentModule decls exps) =
137136 updateImportRef :: Declaration -> m Declaration
138137 updateImportRef (PositionedDeclaration pos com d) =
139138 warnAndRethrowWithPosition pos $ PositionedDeclaration pos com <$> updateImportRef d
140− updateImportRef (ImportDeclaration mn typ qual isOldSyntax) = do
139+ updateImportRef (ImportDeclaration mn typ qual) = do
141140 modExports <- getExports env mn
142141 typ' <- case typ of
143142 Implicit -> return Implicit
144143 Explicit refs -> Explicit <$> updateProperRef mn modExports `traverse` refs
145144 Hiding refs -> Hiding <$> updateProperRef mn modExports `traverse` refs
146− return $ ImportDeclaration mn typ' qual isOldSyntax
145+ return $ ImportDeclaration mn typ' qual
147146 updateImportRef other = return other
148147
149148 updateProperRef :: ModuleName -> Exports -> DeclarationRef -> m DeclarationRef
tests/TestPsci.hs+1−3
@@ -60,7 +60,6 @@ completionTestData =
6060 -- import should complete module names
6161 , ("import Control.Monad.E", map ("import Control.Monad.Eff" ++) ["", ".Unsafe", ".Class", ".Console"])
6262 , ("import Control.Monad.Eff.", map ("import Control.Monad.Eff" ++) [".Unsafe", ".Class", ".Console"])
63− , ("import qualified Control.Monad.Eff.", map ("import qualified Control.Monad.Eff" ++) [".Unsafe", ".Class", ".Console"])
6463
6564 -- :load, :module should complete file paths
6665 , (":l tests/support/psci/", [":l tests/support/psci/Sample.purs"])
@@ -91,8 +90,7 @@ completionTestData =
9190
9291 -- a few other import tests
9392 , ("impor", ["import"])
94− , ("import q", ["import qualified"])
95− , ("import ", map ("import " ++) supportModules ++ ["import qualified"])
93+ , ("import ", map ("import " ++) supportModules)
9694 , ("import Prelude ", [])
9795
9896 -- String and number literals should not be completed