diff options
| author | Jan Tuomi <jan.tuomi@valuemotive.com> | 2022-09-23 11:12:55 +0300 |
|---|---|---|
| committer | Jan Tuomi <jans.tuomi@gmail.com> | 2022-12-05 14:21:52 +0200 |
| commit | 89a6e5d5a4ab10a5dbc70e891499db851896ac7d (patch) | |
| tree | 1f1278e9a846ec47a800a39e20591907aaaa6b73 /app | |
| parent | 335ed87f5d672fd6a3de856fef62963c2946318f (diff) | |
Make REPL work
Diffstat (limited to 'app')
| -rw-r--r-- | app/Main.hs | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/app/Main.hs b/app/Main.hs index 6115252..1829c62 100644 --- a/app/Main.hs +++ b/app/Main.hs @@ -17,15 +17,17 @@ parseArgs config args = config { configShowHelp = True } rest _ -> config -repl :: InputT IO () -repl = do +repl :: Config -> InputT IO () +repl config = do minput <- getInputLine "> " case minput of Nothing -> return () - Just "exit" -> return () Just input -> do - outputStrLn $ "Input was: " ++ input - repl + result <- lift $ runExceptT $ runReaderT (runInlineScript input) config + case result of + Left (LException ex) -> outputStrLn $ "Error: " ++ ex + Right () -> outputStrLn $ input + repl config main :: IO () main = do @@ -56,5 +58,7 @@ main = do Left (LException ex) -> putStrLn $ "Error: " ++ ex Right () -> return () Nothing -> do - runInputT defaultSettings repl + putStrLn $ "Lang REPL" + putStrLn $ "Use CTRL+D to exit" + runInputT defaultSettings (repl config) return () |
