28 lines
534 B
Haskell
28 lines
534 B
Haskell
module Main (main) where
|
|
|
|
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
|
|
|
|
main :: IO ()
|
|
main = repl
|