Skip to content

Commit

Permalink
Add necessary Axel imports to transpiled files (see #81)
Browse files Browse the repository at this point in the history
  • Loading branch information
jgrosso committed Dec 29, 2022
1 parent 9059b74 commit 91f323d
Show file tree
Hide file tree
Showing 39 changed files with 233 additions and 154 deletions.
8 changes: 6 additions & 2 deletions README.org
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,15 @@
See [[https://axellang.github.io]].
#+CAPTION: Build Status
[[https://travis-ci.org/axellang/axel.svg?branch=master]]

*CURRENT STATUS:* I'm currently recovering from some academic burnout (much to my chagrin), hence the dearth of recent activity. I promise that Axel is /not/ abandoned, and active development should resume within the next several months.
** Code Style
Run ~scripts/format.sh~ to format code and ~scripts/lint.sh~ to run the linter.
** Running
Run ~cabal run -- axel <arguments>~ to build and run the project and ~scripts/test.sh~ to test the project.
Run ~cabal run -- axel <arguments>~ to build and run the project.
** Testing
Run ~scripts/test.sh~ to test the project.
*** Golden Tests
To prevent issues like #79: Before committing any new (or modified) golden tests, run `cabal exec ghci -- -package axel` (or equivalent) on the corresponding `hs` files to ensure that they actually parse. (It's okay if they don't compile or evaluate, as long as they are valid Haskell.)
** Examples
See the ~.axel~ files in this repository for example Axel programs.
5 changes: 3 additions & 2 deletions app/Main.hs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
module Main where
import Axel
import qualified Prelude as GHCPrelude
import qualified Axel.Parse.AST as AST
import qualified Prelude as AxelRuntime_GHCPrelude
import qualified Axel.Parse.AST as AxelRuntime_AST
import qualified Axel.Sourcemap as AxelRuntime_Sourcemap
import Axel.Eff.App(AppEffs,runApp)
import Axel.Eff.Console(putStrLn)
import Axel.Eff.Ghci(withGhci)
Expand Down
1 change: 1 addition & 0 deletions src/Axel.axel
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

(import Axel.Prelude all)
(import Axel.Parse [hygenisizeIdentifier])
(importq Axel.Parse.AST AST all)
(importq Axel.Sourcemap SM all)
(import Axel.Utils.FilePath [takeFileName])
(import Data.IORef [IORef modifyIORef newIORef readIORef])
Expand Down
38 changes: 20 additions & 18 deletions src/Axel.hs
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
{-# OPTIONS_GHC -Wno-incomplete-patterns #-}
module Axel where
import qualified Prelude as GHCPrelude
import qualified Axel.Parse.AST as AST
import qualified Prelude as AxelRuntime_GHCPrelude
import qualified Axel.Parse.AST as AxelRuntime_AST
import qualified Axel.Sourcemap as AxelRuntime_Sourcemap
import Axel.Prelude
import Axel.Parse(hygenisizeIdentifier)
import qualified Axel.Parse.AST as AST
import qualified Axel.Sourcemap as SM
import Axel.Utils.FilePath(takeFileName)
import Data.IORef(IORef,modifyIORef,newIORef,readIORef)
Expand All @@ -13,9 +15,9 @@ aXEL_SYMBOL_IF_ :: () => ((->) Bool ((->) a ((->) a a)))
aXEL_SYMBOL_IF_ True x _ = x
aXEL_SYMBOL_IF_ False _ x = x
expandDo :: () => ((->) ([] SM.Expression) SM.Expression)
expandDo ((:) (AST.SExpression _ [(AST.Symbol _ "<-"),var,val]) rest) = (AST.SExpression (GHCPrelude.Just ((,) "src/Axel.axel" (SM.Position 43 8))) (concat [[(AST.Symbol (GHCPrelude.Just ((,) "axelTemp/5670498282835698530/result.axel" (SM.Position 2 156))) ">>=")],[val],[(AST.SExpression (GHCPrelude.Just ((,) "src/Axel.axel" (SM.Position 43 18))) (concat [[(AST.Symbol (GHCPrelude.Just ((,) "axelTemp/5670498282835698530/result.axel" (SM.Position 2 254))) "\\")],[(AST.SExpression (GHCPrelude.Just ((,) "src/Axel.axel" (SM.Position 43 21))) (concat [[(AST.Symbol (GHCPrelude.Just ((,) "axelTemp/5670498282835698530/result.axel" (SM.Position 2 344))) "list")],[var]]))],[(expandDo rest)]]))]]))
expandDo ((:) (AST.SExpression _ ((:) (AST.Symbol _ "aXEL_SYMBOL_LET_") bindings)) rest) = (AST.SExpression (GHCPrelude.Just ((,) "src/Axel.axel" (SM.Position 45 8))) (concat [[(AST.Symbol (GHCPrelude.Just ((,) "axelTemp/5670498282835698530/result.axel" (SM.Position 3 173))) "aXEL_SYMBOL_LET_")],[(AST.SExpression (GHCPrelude.Just ((,) "src/Axel.axel" (SM.Position 45 13))) (concat [[(AST.Symbol (GHCPrelude.Just ((,) "axelTemp/5670498282835698530/result.axel" (SM.Position 3 278))) "list")],(AST.toExpressionList bindings)]))],[(expandDo rest)]]))
expandDo ((:) val rest) = (case rest of {[] -> val;_ -> (AST.SExpression (GHCPrelude.Just ((,) "src/Axel.axel" (SM.Position 47 31))) (concat [[(AST.Symbol (GHCPrelude.Just ((,) "axelTemp/5670498282835698530/result.axel" (SM.Position 4 137))) ">>")],[val],[(expandDo rest)]]))})
expandDo ((:) (AST.SExpression _ [(AxelRuntime_AST.Symbol _ "<-"),var,val]) rest) = (AxelRuntime_AST.SExpression (AxelRuntime_GHCPrelude.Just ((,) "src/Axel.axel" (AxelRuntime_Sourcemap.Position 44 8))) (concat [[(AxelRuntime_AST.Symbol (AxelRuntime_GHCPrelude.Just ((,) "axelTemp/3735029020733611241/result.axel" (AxelRuntime_Sourcemap.Position 2 199))) ">>=")],[val],[(AxelRuntime_AST.SExpression (AxelRuntime_GHCPrelude.Just ((,) "src/Axel.axel" (AxelRuntime_Sourcemap.Position 44 18))) (concat [[(AxelRuntime_AST.Symbol (AxelRuntime_GHCPrelude.Just ((,) "axelTemp/3735029020733611241/result.axel" (AxelRuntime_Sourcemap.Position 2 340))) "\\")],[(AxelRuntime_AST.SExpression (AxelRuntime_GHCPrelude.Just ((,) "src/Axel.axel" (AxelRuntime_Sourcemap.Position 44 21))) (concat [[(AxelRuntime_AST.Symbol (AxelRuntime_GHCPrelude.Just ((,) "axelTemp/3735029020733611241/result.axel" (AxelRuntime_Sourcemap.Position 2 473))) "list")],[var]]))],[(expandDo rest)]]))]]))
expandDo ((:) (AST.SExpression _ ((:) (AxelRuntime_AST.Symbol _ "aXEL_SYMBOL_LET_") bindings)) rest) = (AxelRuntime_AST.SExpression (AxelRuntime_GHCPrelude.Just ((,) "src/Axel.axel" (AxelRuntime_Sourcemap.Position 46 8))) (concat [[(AxelRuntime_AST.Symbol (AxelRuntime_GHCPrelude.Just ((,) "axelTemp/3735029020733611241/result.axel" (AxelRuntime_Sourcemap.Position 3 216))) "aXEL_SYMBOL_LET_")],[(AxelRuntime_AST.SExpression (AxelRuntime_GHCPrelude.Just ((,) "src/Axel.axel" (AxelRuntime_Sourcemap.Position 46 13))) (concat [[(AxelRuntime_AST.Symbol (AxelRuntime_GHCPrelude.Just ((,) "axelTemp/3735029020733611241/result.axel" (AxelRuntime_Sourcemap.Position 3 364))) "list")],(AxelRuntime_AST.toExpressionList bindings)]))],[(expandDo rest)]]))
expandDo ((:) val rest) = (case rest of {[] -> val;_ -> (AxelRuntime_AST.SExpression (AxelRuntime_GHCPrelude.Just ((,) "src/Axel.axel" (AxelRuntime_Sourcemap.Position 48 31))) (concat [[(AxelRuntime_AST.Symbol (AxelRuntime_GHCPrelude.Just ((,) "axelTemp/3735029020733611241/result.axel" (AxelRuntime_Sourcemap.Position 4 180))) ">>")],[val],[(expandDo rest)]]))})
gensymCounter :: () => (IORef Int)
gensymCounter = (unsafePerformIO (newIORef 0))
{-# NOINLINE gensymCounter #-}
Expand All @@ -25,18 +27,18 @@ isPrelude :: () => ((->) FilePath Bool)
isPrelude = ((.) ((==) (FilePath "Axel.axel")) takeFileName)
preludeMacros :: () => ([] Text)
preludeMacros = (map ((.) T.pack hygenisizeIdentifier) ["|","applyInfix","defmacro","def","do","\\case","syntaxQuote"])
applyInfix_AXEL_AUTOGENERATED_MACRO_DEFINITION [op,x] = (pure [(AST.SExpression (GHCPrelude.Just ((,) "src/Axel.axel" (SM.Position 13 35))) (concat [[(AST.Symbol (GHCPrelude.Just ((,) "src/Axel.axel" (SM.Position 13 36))) "flip")],[op],[x]]))])
applyInfix_AXEL_AUTOGENERATED_MACRO_DEFINITION [x,op,y] = (pure [(AST.SExpression (GHCPrelude.Just ((,) "src/Axel.axel" (SM.Position 15 37))) (concat [[op],[x],[y]]))])
defmacro_AXEL_AUTOGENERATED_MACRO_DEFINITION ((:) name cases) = (pure (map (\(AST.SExpression _ ((:) args body)) -> (AST.SExpression (GHCPrelude.Just ((,) "src/Axel.axel" (SM.Position 19 24))) (concat [[(AST.Symbol (GHCPrelude.Just ((,) "src/Axel.axel" (SM.Position 19 25))) "aXEL_VALUE_aXEL_SYMBOL_EQUALS_macro")],[name],[args],(AST.toExpressionList body)]))) cases))
def_AXEL_AUTOGENERATED_MACRO_DEFINITION ((:) name ((:) typeSig cases)) = (pure ((:) (AST.SExpression (GHCPrelude.Just ((,) "src/Axel.axel" (SM.Position 25 15))) (concat [[(AST.Symbol (GHCPrelude.Just ((,) "axelTemp/6491493558012962605/result.axel" (SM.Position 1 164))) "::")],[name],(AST.toExpressionList typeSig)])) (map (\(AST.SExpression _ ((:) (AST.SExpression _ ((:) (AST.Symbol _ "list") args)) xs)) -> (AST.SExpression (GHCPrelude.Just ((,) "src/Axel.axel" (SM.Position 31 17))) (concat [[(AST.Symbol (GHCPrelude.Just ((,) "axelTemp/6491493558012962605/result.axel" (SM.Position 1 383))) "=")],[(AST.SExpression (GHCPrelude.Just ((,) "src/Axel.axel" (SM.Position 31 20))) (concat [[name],(AST.toExpressionList args)]))],(AST.toExpressionList xs)]))) cases)))
applyInfix_AXEL_AUTOGENERATED_MACRO_DEFINITION [op,x] = (pure [(AxelRuntime_AST.SExpression (AxelRuntime_GHCPrelude.Just ((,) "src/Axel.axel" (AxelRuntime_Sourcemap.Position 14 35))) (concat [[(AxelRuntime_AST.Symbol (AxelRuntime_GHCPrelude.Just ((,) "src/Axel.axel" (AxelRuntime_Sourcemap.Position 14 36))) "flip")],[op],[x]]))])
applyInfix_AXEL_AUTOGENERATED_MACRO_DEFINITION [x,op,y] = (pure [(AxelRuntime_AST.SExpression (AxelRuntime_GHCPrelude.Just ((,) "src/Axel.axel" (AxelRuntime_Sourcemap.Position 16 37))) (concat [[op],[x],[y]]))])
defmacro_AXEL_AUTOGENERATED_MACRO_DEFINITION ((:) name cases) = (pure (map (\(AST.SExpression _ ((:) args body)) -> (AxelRuntime_AST.SExpression (AxelRuntime_GHCPrelude.Just ((,) "src/Axel.axel" (AxelRuntime_Sourcemap.Position 20 24))) (concat [[(AxelRuntime_AST.Symbol (AxelRuntime_GHCPrelude.Just ((,) "src/Axel.axel" (AxelRuntime_Sourcemap.Position 20 25))) "aXEL_VALUE_aXEL_SYMBOL_EQUALS_macro")],[name],[args],(AxelRuntime_AST.toExpressionList body)]))) cases))
def_AXEL_AUTOGENERATED_MACRO_DEFINITION ((:) name ((:) typeSig cases)) = (pure ((:) (AxelRuntime_AST.SExpression (AxelRuntime_GHCPrelude.Just ((,) "src/Axel.axel" (AxelRuntime_Sourcemap.Position 26 15))) (concat [[(AxelRuntime_AST.Symbol (AxelRuntime_GHCPrelude.Just ((,) "axelTemp/2511363082445148512/result.axel" (AxelRuntime_Sourcemap.Position 1 207))) "::")],[name],(AxelRuntime_AST.toExpressionList typeSig)])) (map (\(AST.SExpression _ ((:) (AST.SExpression _ ((:) (AST.Symbol _ "list") args)) xs)) -> (AxelRuntime_AST.SExpression (AxelRuntime_GHCPrelude.Just ((,) "src/Axel.axel" (AxelRuntime_Sourcemap.Position 32 17))) (concat [[(AxelRuntime_AST.Symbol (AxelRuntime_GHCPrelude.Just ((,) "axelTemp/2511363082445148512/result.axel" (AxelRuntime_Sourcemap.Position 1 481))) "=")],[(AxelRuntime_AST.SExpression (AxelRuntime_GHCPrelude.Just ((,) "src/Axel.axel" (AxelRuntime_Sourcemap.Position 32 20))) (concat [[name],(AxelRuntime_AST.toExpressionList args)]))],(AxelRuntime_AST.toExpressionList xs)]))) cases)))
syntaxQuote_AXEL_AUTOGENERATED_MACRO_DEFINITION [x] = (pure [(AST.quoteExpression (const (AST.Symbol Nothing "_")) x)])
aXEL_SYMBOL_DO__AXEL_AUTOGENERATED_MACRO_DEFINITION input = (pure [(expandDo input)])
aXEL_VALUE_aXEL_SYMBOL_BACKSLASH_case_AXEL_AUTOGENERATED_MACRO_DEFINITION cases = (fmap (\varId -> [(AST.SExpression (GHCPrelude.Just ((,) "src/Axel.axel" (SM.Position 67 28))) (concat [[(AST.Symbol (GHCPrelude.Just ((,) "src/Axel.axel" (SM.Position 67 29))) "\\")],[(AST.SExpression (GHCPrelude.Just ((,) "src/Axel.axel" (SM.Position 67 31))) (concat [[(AST.Symbol GHCPrelude.Nothing "list")],[varId]]))],[(AST.SExpression (GHCPrelude.Just ((,) "src/Axel.axel" (SM.Position 67 40))) (concat [[(AST.Symbol (GHCPrelude.Just ((,) "src/Axel.axel" (SM.Position 67 41))) "case")],[varId],(AST.toExpressionList cases)]))]]))]) gensym)
(|%%%%%%%%%%) cases = (pure [(foldr (\(AST.SExpression _ [cond,x]) acc -> (AST.SExpression (GHCPrelude.Just ((,) "src/Axel.axel" (SM.Position 73 51))) (concat [[(AST.Symbol (GHCPrelude.Just ((,) "src/Axel.axel" (SM.Position 73 52))) "aXEL_SYMBOL_IF_")],[cond],[x],[acc]]))) (AST.Symbol (GHCPrelude.Just ((,) "src/Axel.axel" (SM.Position 74 13))) "undefined") cases)])
applyInfix_AXEL_AUTOGENERATED_MACRO_DEFINITION :: [AST.Expression SM.SourceMetadata] -> GHCPrelude.IO [AST.Expression SM.SourceMetadata]
defmacro_AXEL_AUTOGENERATED_MACRO_DEFINITION :: [AST.Expression SM.SourceMetadata] -> GHCPrelude.IO [AST.Expression SM.SourceMetadata]
def_AXEL_AUTOGENERATED_MACRO_DEFINITION :: [AST.Expression SM.SourceMetadata] -> GHCPrelude.IO [AST.Expression SM.SourceMetadata]
syntaxQuote_AXEL_AUTOGENERATED_MACRO_DEFINITION :: [AST.Expression SM.SourceMetadata] -> GHCPrelude.IO [AST.Expression SM.SourceMetadata]
aXEL_SYMBOL_DO__AXEL_AUTOGENERATED_MACRO_DEFINITION :: [AST.Expression SM.SourceMetadata] -> GHCPrelude.IO [AST.Expression SM.SourceMetadata]
aXEL_VALUE_aXEL_SYMBOL_BACKSLASH_case_AXEL_AUTOGENERATED_MACRO_DEFINITION :: [AST.Expression SM.SourceMetadata] -> GHCPrelude.IO [AST.Expression SM.SourceMetadata]
(|%%%%%%%%%%) :: [AST.Expression SM.SourceMetadata] -> GHCPrelude.IO [AST.Expression SM.SourceMetadata]
aXEL_VALUE_aXEL_SYMBOL_BACKSLASH_case_AXEL_AUTOGENERATED_MACRO_DEFINITION cases = (fmap (\varId -> [(AxelRuntime_AST.SExpression (AxelRuntime_GHCPrelude.Just ((,) "src/Axel.axel" (AxelRuntime_Sourcemap.Position 68 28))) (concat [[(AxelRuntime_AST.Symbol (AxelRuntime_GHCPrelude.Just ((,) "src/Axel.axel" (AxelRuntime_Sourcemap.Position 68 29))) "\\")],[(AxelRuntime_AST.SExpression (AxelRuntime_GHCPrelude.Just ((,) "src/Axel.axel" (AxelRuntime_Sourcemap.Position 68 31))) (concat [[(AxelRuntime_AST.Symbol AxelRuntime_GHCPrelude.Nothing "list")],[varId]]))],[(AxelRuntime_AST.SExpression (AxelRuntime_GHCPrelude.Just ((,) "src/Axel.axel" (AxelRuntime_Sourcemap.Position 68 40))) (concat [[(AxelRuntime_AST.Symbol (AxelRuntime_GHCPrelude.Just ((,) "src/Axel.axel" (AxelRuntime_Sourcemap.Position 68 41))) "case")],[varId],(AxelRuntime_AST.toExpressionList cases)]))]]))]) gensym)
(|%%%%%%%%%%) cases = (pure [(foldr (\(AST.SExpression _ [cond,x]) acc -> (AxelRuntime_AST.SExpression (AxelRuntime_GHCPrelude.Just ((,) "src/Axel.axel" (AxelRuntime_Sourcemap.Position 74 51))) (concat [[(AxelRuntime_AST.Symbol (AxelRuntime_GHCPrelude.Just ((,) "src/Axel.axel" (AxelRuntime_Sourcemap.Position 74 52))) "aXEL_SYMBOL_IF_")],[cond],[x],[acc]]))) (AxelRuntime_AST.Symbol (AxelRuntime_GHCPrelude.Just ((,) "src/Axel.axel" (AxelRuntime_Sourcemap.Position 75 13))) "undefined") cases)])
applyInfix_AXEL_AUTOGENERATED_MACRO_DEFINITION :: [AxelRuntime_AST.Expression AxelRuntime_Sourcemap.SourceMetadata] -> AxelRuntime_GHCPrelude.IO [AxelRuntime_AST.Expression AxelRuntime_Sourcemap.SourceMetadata]
defmacro_AXEL_AUTOGENERATED_MACRO_DEFINITION :: [AxelRuntime_AST.Expression AxelRuntime_Sourcemap.SourceMetadata] -> AxelRuntime_GHCPrelude.IO [AxelRuntime_AST.Expression AxelRuntime_Sourcemap.SourceMetadata]
def_AXEL_AUTOGENERATED_MACRO_DEFINITION :: [AxelRuntime_AST.Expression AxelRuntime_Sourcemap.SourceMetadata] -> AxelRuntime_GHCPrelude.IO [AxelRuntime_AST.Expression AxelRuntime_Sourcemap.SourceMetadata]
syntaxQuote_AXEL_AUTOGENERATED_MACRO_DEFINITION :: [AxelRuntime_AST.Expression AxelRuntime_Sourcemap.SourceMetadata] -> AxelRuntime_GHCPrelude.IO [AxelRuntime_AST.Expression AxelRuntime_Sourcemap.SourceMetadata]
aXEL_SYMBOL_DO__AXEL_AUTOGENERATED_MACRO_DEFINITION :: [AxelRuntime_AST.Expression AxelRuntime_Sourcemap.SourceMetadata] -> AxelRuntime_GHCPrelude.IO [AxelRuntime_AST.Expression AxelRuntime_Sourcemap.SourceMetadata]
aXEL_VALUE_aXEL_SYMBOL_BACKSLASH_case_AXEL_AUTOGENERATED_MACRO_DEFINITION :: [AxelRuntime_AST.Expression AxelRuntime_Sourcemap.SourceMetadata] -> AxelRuntime_GHCPrelude.IO [AxelRuntime_AST.Expression AxelRuntime_Sourcemap.SourceMetadata]
(|%%%%%%%%%%) :: [AxelRuntime_AST.Expression AxelRuntime_Sourcemap.SourceMetadata] -> AxelRuntime_GHCPrelude.IO [AxelRuntime_AST.Expression AxelRuntime_Sourcemap.SourceMetadata]
11 changes: 4 additions & 7 deletions src/Axel/AST.hs
Original file line number Diff line number Diff line change
Expand Up @@ -495,17 +495,14 @@ instance ToHaskell (DataDeclaration (Maybe SM.Expression)) where
Parentheses
(SM.delimit Commas $ map toHaskell $ dataDeclaration ^. derivedConstraints)
where
tryRemoveSurroundingParentheses :: SM.Output -> SM.Output
tryRemoveSurroundingParentheses xs =
if "(" `T.isPrefixOf` (xs ^. _Wrapped . _head . unannotated)
then removeSurroundingParentheses xs
then let removeOpen = _Wrapped . _head . unannotated %~ T.tail
removeClosed = _Wrapped . _last . unannotated %~ T.init
in removeOpen $ removeClosed xs
else xs

removeSurroundingParentheses :: SM.Output -> SM.Output
removeSurroundingParentheses = removeOpen . removeClosed
where
removeOpen = _Wrapped . _head . unannotated %~ T.tail
removeClosed = _Wrapped . _last . unannotated %~ T.init

instance ToHaskell (NewtypeDeclaration (Maybe SM.Expression)) where
toHaskell :: NewtypeDeclaration (Maybe SM.Expression) -> SM.Output
toHaskell newtypeDeclaration =
Expand Down
5 changes: 3 additions & 2 deletions src/Axel/Haskell/Macros.hs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
module Axel.Haskell.Macros where
import Axel
import qualified Prelude as GHCPrelude
import qualified Axel.Parse.AST as AST
import qualified Prelude as AxelRuntime_GHCPrelude
import qualified Axel.Parse.AST as AxelRuntime_AST
import qualified Axel.Sourcemap as AxelRuntime_Sourcemap
import Axel.Prelude
import Axel.Haskell.Language(isOperator)
import qualified Data.Text as T
Expand Down
41 changes: 29 additions & 12 deletions src/Axel/Macros.hs
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ mkMacroTypeSignature :: Identifier -> SMStatement
mkMacroTypeSignature macroName =
SRawStatement Nothing $
SM.raw (toHaskell (EIdentifier (Nothing :: Maybe SM.Expression) macroName)) <>
" :: [AST.Expression SM.SourceMetadata] -> GHCPrelude.IO [AST.Expression SM.SourceMetadata]"
" :: [AxelRuntime_AST.Expression AxelRuntime_Sourcemap.SourceMetadata] -> AxelRuntime_GHCPrelude.IO [AxelRuntime_AST.Expression AxelRuntime_Sourcemap.SourceMetadata]"

newtype ExpansionId =
ExpansionId Text
Expand All @@ -394,9 +394,23 @@ autogeneratedImports filePath
| not $ isPrelude filePath
] <>
[ SQualifiedImport $
QualifiedImport Nothing "Prelude" "GHCPrelude" (ImportAll Nothing) -- (in case `-XNoImplicitPrelude` is enabled)
QualifiedImport
Nothing
"Prelude"
"AxelRuntime_GHCPrelude"
(ImportAll Nothing) -- (in case `-XNoImplicitPrelude` is enabled)
, SQualifiedImport $
QualifiedImport Nothing "Axel.Parse.AST" "AST" (ImportAll Nothing)
QualifiedImport
Nothing
"Axel.Parse.AST"
"AxelRuntime_AST"
(ImportAll Nothing)
, SQualifiedImport $
QualifiedImport
Nothing
"Axel.Sourcemap"
"AxelRuntime_Sourcemap"
(ImportAll Nothing)
]

generateMacroProgram ::
Expand Down Expand Up @@ -436,14 +450,15 @@ generateMacroProgram filePath' oldMacroName args = do
mkList xs =
mkFnApp (mkId "[") $ intersperse (mkRawExpr ",") xs <> [mkId "]"] -- This is VERY hacky, but it'll work without too much effort for now.
in ( autogeneratedImports filePath' <>
[mkQualImport "Axel.Sourcemap" "SM"]
[mkQualImport "Axel.Sourcemap" "AxelRuntime_Sourcemap"]
, mkModuleDecl scaffoldModuleName : autogeneratedImports filePath' <>
[ mkQualImport macroDefAndEnvModuleName macroDefAndEnvModuleName
, mkQualImport "Axel.Sourcemap" "SM"
, mkTySig "main" $ mkFnApp (mkId "GHCPrelude.IO") [mkId "()"]
, mkQualImport "Axel.Sourcemap" "AxelRuntime_Sourcemap"
, mkTySig "main" $
mkFnApp (mkId "AxelRuntime_GHCPrelude.IO") [mkId "()"]
, mkFnDef "main" [] $
mkFnApp
(mkId "(GHCPrelude.>>=)")
(mkId "(AxelRuntime_GHCPrelude.>>=)")
[ mkFnApp
(mkQualId
macroDefAndEnvModuleName
Expand All @@ -455,12 +470,14 @@ generateMacroProgram filePath' oldMacroName args = do
args)
]
, mkFnApp
(mkId "(GHCPrelude..)")
[ mkId "GHCPrelude.putStrLn"
(mkId "(AxelRuntime_GHCPrelude..)")
[ mkId "AxelRuntime_GHCPrelude.putStrLn"
, mkFnApp
(mkId "(GHCPrelude..)")
[ mkId "GHCPrelude.unlines"
, mkFnApp (mkId "GHCPrelude.map") [mkId "AST.toAxel'"]
(mkId "(AxelRuntime_GHCPrelude..)")
[ mkId "AxelRuntime_GHCPrelude.unlines"
, mkFnApp
(mkId "AxelRuntime_GHCPrelude.map")
[mkId "AxelRuntime_AST.toAxel'"]
]
]
]
Expand Down
Loading

0 comments on commit 91f323d

Please sign in to comment.