summaryrefslogtreecommitdiff
path: root/Main.hs
diff options
context:
space:
mode:
Diffstat (limited to 'Main.hs')
-rw-r--r--Main.hs10
1 files changed, 5 insertions, 5 deletions
diff --git a/Main.hs b/Main.hs
index b56edfe..ef98b62 100644
--- a/Main.hs
+++ b/Main.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE LambdaCase, TupleSections #-}
module Main where
import System.Environment
@@ -16,13 +17,12 @@ usage = do
main :: IO ()
main = do
- clargs <- getArgs
- source <- case clargs of
- [] -> getContents
- [fname] -> readFile fname
+ (mfname, source) <- getArgs >>= \case
+ [] -> (Nothing,) <$> getContents
+ [arg] -> (Just arg,) <$> readFile arg
_ -> usage >> exitFailure
- prog <- parseProgram source >>= either (die . show) return
+ prog <- parseProgram mfname source >>= either (die . show) return
irprog <- either die return (compileProgram prog)
let opt = optimise irprog
-- print opt