summaryrefslogtreecommitdiffstats
path: root/src/main.hs
diff options
context:
space:
mode:
authorJan Tuomi <jans.tuomi@gmail.com>2022-01-31 22:49:36 +0200
committerJan Tuomi <jans.tuomi@gmail.com>2022-01-31 22:49:36 +0200
commitb235c2887ed60a8fd48263f6c53e90ee7e2073fd (patch)
tree2a47ec5bc38ef95b65b130d277e6ba41dc9f2213 /src/main.hs
parent7390af67e18e6d17934541dd3c2d6d46cfad84d0 (diff)
Some general refactoring
Diffstat (limited to 'src/main.hs')
-rw-r--r--src/main.hs14
1 files changed, 8 insertions, 6 deletions
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