hc/app/Main.hs

24 lines
479 B
Haskell
Raw Normal View History

module Main (main) where
2024-09-15 16:47:34 +02:00
import Text.Parsec
import Lib (exprparser, evaluate)
import System.IO
main :: IO ()
2024-09-15 16:47:34 +02:00
main = ioLoop
useResult (Right e) = show . evaluate $ e
useResult (Left e) = show e
ioLoop :: IO ()
ioLoop = do done <- isEOF
if done
then putStrLn "Quit!"
else do inp <- getLine
let expr = parse exprparser "<stdin>" inp
putStrLn . useResult $ expr
ioLoop