From b235c2887ed60a8fd48263f6c53e90ee7e2073fd Mon Sep 17 00:00:00 2001 From: Jan Tuomi Date: Mon, 31 Jan 2022 22:49:36 +0200 Subject: Some general refactoring --- src/main.hs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'src/main.hs') diff --git a/src/main.hs b/src/main.hs index 39caad9..e23dcf3 100644 --- a/src/main.hs +++ b/src/main.hs @@ -10,6 +10,7 @@ import LTypes import Parser import System.Environment (getArgs) import System.Exit (exitFailure, exitSuccess) +import System.IO (BufferMode (NoBuffering), hSetBuffering, stdin) import Utils getConfig config [] = config @@ -24,7 +25,7 @@ getFileName :: Config -> ExceptT LException IO String getFileName Config {configFileNameM = fileNameM} = do case fileNameM of Just str -> pure str - Nothing -> throwError $ LException "no file name specified" + Nothing -> throwError $ LException "no filename specified" bootstrap :: [String] -> ExceptT LException IO () bootstrap args = do @@ -33,6 +34,7 @@ bootstrap args = do { configFileNameM = Nothing, configDebugMode = False } + let config = getConfig initialConfig args fileName <- getFileName config @@ -51,15 +53,15 @@ bootstrap args = do lSource = parsedSource, lStrLitRefMap = strLitRefMap } - interpretSource config initialState + void $ interpretSource config initialState main :: IO () main = do + hSetBuffering stdin NoBuffering args <- getArgs result <- runExceptT $ bootstrap args case result of - Left ex -> case ex of - LException errStr -> do - putStrLn $ "[error] " ++ errStr - exitFailure + Left (LException errStr) -> do + putStrLn $ "[error] " ++ errStr + exitFailure _ -> exitSuccess -- cgit v1.3