module Main where import Parser import Evaluator import Syntax () import Printer import Text.ParserCombinators.Parsec import System.Environment convert :: Either ParseError a -> Either String a convert (Left err) = Left $ show err convert (Right x) = Right x runProg :: String -> Either String String runProg s = do te <- convert $ parseTerm s (te', _) <- runTC $ compileTerm te c <- eval te' return (pretty c) compileProg :: String -> Either String String compileProg s = do te <- convert $ parseTerm s (te', _) <- runTC $ compileTerm te return (show te') run :: String -> IO () run s = case runProg s of Left err -> print err Right t -> putStrLn t main :: IO () main = do (s:_) <- getArgs run s