aboutsummaryrefslogtreecommitdiffstats
path: root/app/Main.hs
diff options
context:
space:
mode:
authorJan Tuomi <jan.tuomi@valuemotive.com>2022-09-24 15:59:16 +0300
committerJan Tuomi <jans.tuomi@gmail.com>2022-12-05 14:21:53 +0200
commit70468c0217e70858bfa037ad81ce8caf1b582ec2 (patch)
treed2f4a948b59e5236f59d5c480d1bf2db07ae2b76 /app/Main.hs
parentaec05f8d92a608f0fb34fd2453a647b43dcb777d (diff)
Implement let
Diffstat (limited to 'app/Main.hs')
-rw-r--r--app/Main.hs21
1 files changed, 12 insertions, 9 deletions
diff --git a/app/Main.hs b/app/Main.hs
index 978cafc..84e95d2 100644
--- a/app/Main.hs
+++ b/app/Main.hs
@@ -4,6 +4,7 @@ import Control.Monad.Except
import Control.Monad.Reader
import System.Console.Haskeline
import Types
+import Builtins
import Lib
parseArgs :: Config -> [String] -> Config
@@ -17,17 +18,19 @@ parseArgs config args =
config { configShowHelp = True } rest
_ -> config
-repl :: Config -> InputT IO ()
-repl config = do
+repl :: Config -> Env -> InputT IO ()
+repl config env = do
minput <- getInputLine "> "
case minput of
Nothing -> return ()
Just input -> do
- result <- lift $ runExceptT $ runReaderT (runInlineScript input) config
+ result <- lift $ runExceptT $ runReaderT (runInlineScript env input) config
case result of
- Left (LException ex) -> outputStrLn $ "Error: " ++ ex
- Right () -> return ()
- repl config
+ Left (LException ex) -> do
+ outputStrLn $ "Error: " ++ ex
+ repl config env
+ Right newEnv -> do
+ repl config newEnv
main :: IO ()
main = do
@@ -53,12 +56,12 @@ main = do
case (configScriptFileName config) of
Just scriptFileName -> do
- result <- runExceptT $ runReaderT (runScriptFile scriptFileName) config
+ result <- runExceptT $ runReaderT (runScriptFile builtinEnv scriptFileName) config
case result of
Left (LException ex) -> putStrLn $ "Error: " ++ ex
- Right () -> return ()
+ Right _ -> return ()
Nothing -> do
putStrLn $ "Lang REPL"
putStrLn $ "Use CTRL+D to exit"
- runInputT defaultSettings (repl config)
+ runInputT defaultSettings (repl config builtinEnv)
return ()