diff options
Diffstat (limited to 'src/K/Repl.hs')
-rw-r--r-- | src/K/Repl.hs | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/K/Repl.hs b/src/K/Repl.hs new file mode 100644 index 0000000..26f21e1 --- /dev/null +++ b/src/K/Repl.hs @@ -0,0 +1,22 @@ +module K.Repl where + +import Control.Monad.IO.Class +import K.Parsing +import K.Eval +import System.Console.Haskeline + +process :: String -> IO () +process line = do + let res = parseExpr line + case res of + Left err -> print err + Right ex -> print $ eval ex + +main :: IO () +main = runInputT defaultSettings loop + where + loop = do + minput <- getInputLine "Repl> " + case minput of + Nothing -> outputStrLn "Goodbye." + Just input -> (liftIO $ process input) >> loop |