lambda/app/Main.hs

29 lines
534 B
Haskell
Raw Permalink Normal View History

2024-06-20 14:31:39 -07:00
module Main (main) where
2024-08-28 12:49:47 -07:00
import System.IO
import Parser (pAll)
import Lambda (betaReduce, Term)
interaction :: Term -> IO ()
interaction t = do
print t
putStr "? "
hFlush stdout
input <- getLine
if input == "q" then
pure ()
else
interaction (betaReduce t)
repl :: IO ()
repl = do
putStr "> "
hFlush stdout
input <- getLine
case pAll input of
Left err -> putStrLn ("\n" ++ "ERROR: " ++ err) >> repl
Right t -> interaction t >> repl
2024-06-20 14:31:39 -07:00
main :: IO ()
2024-08-28 12:49:47 -07:00
main = repl