{-# LANGUAGE LambdaCase #-} {-# LANGUAGE TupleSections #-} module Main where import Data.List (intersperse) import System.Environment (getArgs) import System.Exit (die, exitFailure) import 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