From 89a6e5d5a4ab10a5dbc70e891499db851896ac7d Mon Sep 17 00:00:00 2001 From: Jan Tuomi Date: Fri, 23 Sep 2022 11:12:55 +0300 Subject: Make REPL work --- app/Main.hs | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'app') 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 () -- cgit v1.3