Further library additions and REPL updates

This commit is contained in:
James Eversole
2024-12-27 19:27:04 -06:00
parent c820eda816
commit 44e2169cdb
4 changed files with 21 additions and 14 deletions

View File

@ -14,15 +14,15 @@ repl env = do
putStr "sapling < "
hFlush stdout
input <- getLine
if input == "_:exit"
then putStrLn "Goodbye!"
else if input == ""
then do
case input of
":_exit" ->
putStrLn "Goodbye!"
"" -> do
putStrLn ""
repl env
else do
_ -> do
let clearEnv = Map.delete "__result" env
let newEnv = evalSingle clearEnv (parseSingle input)
newEnv = evalSingle clearEnv (parseSingle input)
case Map.lookup "__result" newEnv of
Just r -> do
putStrLn $ "sapling > " ++ show r
@ -36,4 +36,4 @@ decodeResult tc =
Right str -> "\"" ++ str ++ "\""
Left _ -> case ofNumber tc of
Right num -> "# " ++ show num
Left _ -> "Failed to decode number from Tree"
Left _ -> ""