diff options
author | Tom Smeding <tom@tomsmeding.com> | 2024-02-17 09:22:49 +0100 |
---|---|---|
committer | Tom Smeding <tom@tomsmeding.com> | 2024-02-17 09:22:49 +0100 |
commit | 3faca807fe96f2cefa50023fe373d8bcf1430121 (patch) | |
tree | 00ee8524bb93fb589468edea0502e626f7ff3df2 /src/Main.hs | |
parent | 3ef786673ff8298124cd3b5ef50c35dbb23f77e2 (diff) |
Move to src/, working HLS in examples/
Diffstat (limited to 'src/Main.hs')
-rw-r--r-- | src/Main.hs | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/Main.hs b/src/Main.hs new file mode 100644 index 0000000..c9de0cc --- /dev/null +++ b/src/Main.hs @@ -0,0 +1,27 @@ +{-# LANGUAGE LambdaCase #-} +{-# LANGUAGE TupleSections #-} +module Main where + +import System.Environment (getArgs) +import System.Exit (die, exitFailure) + +import 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 + mapM_ (putStrLn . printErrMsg) errs + exitFailure + These errs res -> do + mapM_ (putStrLn . printErrMsg) errs + return res + That res -> return res + + print prog |