aboutsummaryrefslogtreecommitdiff
path: root/app/Main.hs
diff options
context:
space:
mode:
Diffstat (limited to 'app/Main.hs')
-rw-r--r--app/Main.hs28
1 files changed, 28 insertions, 0 deletions
diff --git a/app/Main.hs b/app/Main.hs
new file mode 100644
index 0000000..b88d508
--- /dev/null
+++ b/app/Main.hs
@@ -0,0 +1,28 @@
+{-# LANGUAGE LambdaCase #-}
+{-# LANGUAGE TupleSections #-}
+module Main where
+
+import Data.List (intersperse)
+import System.Environment (getArgs)
+import System.Exit (die, exitFailure)
+
+import HSVIS.Parser
+
+
+main :: IO ()
+main = do
+ (source, fname) <- getArgs >>= \case
+ [] -> (,"<stdin>") <$> getContents
+ [fname] -> (,fname) <$> readFile fname
+ _ -> die "Usage: hs-visinter [filename.hs]"
+
+ prog <- case parse fname source of
+ This errs -> do
+ sequence_ $ intersperse (putStrLn "") (map (putStrLn . printErrMsg) errs)
+ exitFailure
+ These errs res -> do
+ sequence_ $ intersperse (putStrLn "") (map (putStrLn . printErrMsg) errs)
+ return res
+ That res -> return res
+
+ print prog