Skip to content

Commit 374739e

Browse files
committed
Remove redundant importUnrestricted syntax (fix axellang#46)
1 parent a0e3488 commit 374739e

File tree

11 files changed

+15
-32
lines changed

11 files changed

+15
-32
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
(import Distribution.Simple (defaultMain))
22

3-
(= main (IO Unit)
3+
(def main (IO Unit)
44
(() defaultMain))
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
(module Main)
22

3-
(importUnrestricted Lib)
3+
(import Lib all)
44

5-
(= main (IO Unit)
6-
(() someFunc))
5+
(def main (IO Unit)
6+
(() someFunc))
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
(module Lib)
22

3-
(= someFunc (IO Unit)
3+
(def someFunc (IO Unit)
44
(() (putStrLn "someFunc")))
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
(= main (IO Unit)
1+
(def main (IO Unit)
22
(() (putStrLn "Test suite not yet implemented")))

src/Axel/AST.hs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,6 @@ data Statement ann
256256
| STypeclassInstance (TypeclassInstance ann)
257257
| STypeSignature (TypeSignature ann)
258258
| STypeSynonym (TypeSynonym ann)
259-
| SUnrestrictedImport ann Identifier
260259
deriving (Data, Eq, Functor, Show)
261260

262261
type Program ann = [Statement ann]
@@ -349,7 +348,6 @@ instance {-# OVERLAPPING #-} HasAnnotation (Statement ann) ann where
349348
getAnn (STypeclassInstance typeclassInstance) = getAnn typeclassInstance
350349
getAnn (STypeSignature typeSig) = getAnn typeSig
351350
getAnn (STypeSynonym typeSynonym) = getAnn typeSynonym
352-
getAnn (SUnrestrictedImport ann' _) = ann'
353351

354352
instance {-# OVERLAPPING #-} HasAnnotation (Parse.Expression ann) ann where
355353
getAnn :: Parse.Expression ann -> ann
@@ -405,7 +403,6 @@ instance ToHaskell SMStatement where
405403
toHaskell (STypeclassInstance x) = toHaskell x
406404
toHaskell (STypeSignature x) = toHaskell x
407405
toHaskell (STypeSynonym x) = toHaskell x
408-
toHaskell stmt@(SUnrestrictedImport _ x) = mkHaskell stmt $ "import " <> x
409406

410407
instance ToHaskell (TypeDefinition (Maybe SM.Expression)) where
411408
toHaskell :: TypeDefinition (Maybe SM.Expression) -> SM.Output

src/Axel/Denormalize.hs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import Axel.AST
1515
SMacroImport, SModuleDeclaration, SNewtypeDeclaration, SPragma,
1616
SQualifiedImport, SRawStatement, SRestrictedImport, STopLevel,
1717
STypeSignature, STypeSynonym, STypeclassDefinition,
18-
STypeclassInstance, SUnrestrictedImport)
18+
STypeclassInstance)
1919
, TopLevel(TopLevel)
2020
, TypeDefinition(ProperType, TypeConstructor)
2121
, alias
@@ -300,10 +300,3 @@ denormalizeStatement (STypeSynonym typeSynonym) =
300300
, denormalizeExpression (typeSynonym ^. alias)
301301
, denormalizeExpression (typeSynonym ^. definition)
302302
]
303-
denormalizeStatement stmt@(SUnrestrictedImport _ identifier) =
304-
let ann' = getAnn' stmt
305-
in Parse.SExpression
306-
ann'
307-
[ Parse.Symbol ann' "importUnrestricted"
308-
, Parse.Symbol ann' (T.unpack identifier)
309-
]

src/Axel/Haskell/Convert.hs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -168,15 +168,13 @@ instance ToStmts HSE.ImportDecl where
168168
Nothing -> unsupportedStmt stmt
169169
else case alias of
170170
Nothing ->
171-
case importSpecListToExpr spec of
172-
AST.ImportAll _ ->
173-
AST.SUnrestrictedImport Nothing moduleId
174-
AST.ImportOnly _ imports ->
175-
AST.SRestrictedImport $
176-
AST.RestrictedImport
177-
Nothing
178-
moduleId
179-
(AST.ImportOnly Nothing imports)
171+
let importSpec =
172+
case importSpecListToExpr spec of
173+
AST.ImportAll _ -> AST.ImportAll Nothing
174+
AST.ImportOnly _ imports ->
175+
AST.ImportOnly Nothing imports
176+
in AST.SRestrictedImport $
177+
AST.RestrictedImport Nothing moduleId importSpec
180178
Just _ -> unsupportedStmt stmt
181179
]
182180
where

src/Axel/Normalize.hs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ import Axel.AST
3333
SMacroImport, SModuleDeclaration, SNewtypeDeclaration, SPragma,
3434
SQualifiedImport, SRawStatement, SRestrictedImport, STopLevel,
3535
STypeSignature, STypeSynonym, STypeclassDefinition,
36-
STypeclassInstance, SUnrestrictedImport)
36+
STypeclassInstance)
3737
, TopLevel(TopLevel)
3838
, TypeDefinition(ProperType, TypeConstructor)
3939
, TypeSignature(TypeSignature)
@@ -275,8 +275,6 @@ normalizeStatement expr@(Parse.SExpression _ items) =
275275
SQualifiedImport <$>
276276
(QualifiedImport (Just expr) (T.pack moduleName) (T.pack alias) <$>
277277
normalizeImportSpec importSpec)
278-
[Parse.Symbol _ "importUnrestricted", Parse.Symbol _ moduleName] ->
279-
pure $ SUnrestrictedImport (Just expr) (T.pack moduleName)
280278
Parse.Symbol _ "instance":instanceName:defs ->
281279
let normalizedDefs =
282280
traverse

test/Axel/Test/ASTGen.hs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,6 @@ genStatement =
189189
, AST.STypeclassInstance <$> genTypeclassInstance
190190
, AST.STypeSignature <$> genTypeSignature
191191
, AST.STypeSynonym <$> genTypeSynonym
192-
, AST.SUnrestrictedImport Nothing <$> genIdentifier
193192
]
194193
[ AST.STopLevel <$> genTopLevel
195194
, AST.SFunctionDefinition <$> genFunctionDefinition

test/Axel/Test/Transpilation/syntax/ImportSyntax.axel_golden

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
(importUnrestricted Quux)
21
(import Foo all)
32
(import Bar (foo bar (Baz baz)))
43
(importq Bar Baz all)

test/Axel/Test/Transpilation/syntax/ImportSyntax.hs_golden

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import qualified Prelude as GHCPrelude
22
import qualified Axel.Parse.AST as AST
3-
import Quux
43
import Foo
54
import Bar(foo,bar,Baz(baz))
65
import qualified Bar as Baz

0 commit comments

Comments
 (0)