This repository has been archived on 2024-04-05. You can view files and clone it, but cannot push or open issues/pull-requests.
really-bad-compiler-in-haskell/app/Main.hs

23 lines
466 B
Haskell

module Main (main) where
import Control.Monad
import Data.Either
import Eval.Expression
import Objects.Expression
import Parser.Expression
import System.Environment
import System.IO
import Text.Megaparsec
getRight :: ParseResult -> Expr
getRight (Right r) = r
getResult :: String -> Int
getResult str = evalExpr (getRight (parseExpr str))
main = do
fileName <- fmap head getArgs
contents <- readFile fileName
let result = getResult contents
print result