From c13617684eb10fc622cc502249591002e2f7d74c Mon Sep 17 00:00:00 2001 From: Tom Smeding Date: Sun, 25 Feb 2024 21:04:03 +0100 Subject: Separate out library --- app/Main.hs | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 app/Main.hs (limited to 'app') 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 + [] -> (,"") <$> 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 -- cgit v1.2.3-70-g09d2