hc/app/Main.hs

23 lines
479 B
Haskell

module Main (main) where
import Text.Parsec
import Lib (exprparser, evaluate)
import System.IO
main :: IO ()
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