From ff174d9536db26945189593bf8194f18fbd5ce3f Mon Sep 17 00:00:00 2001 From: evuez Date: Mon, 1 Apr 2024 15:16:52 +0200 Subject: Initial commit --- app/Main.hs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 app/Main.hs (limited to 'app/Main.hs') diff --git a/app/Main.hs b/app/Main.hs new file mode 100644 index 0000000..0b1f81e --- /dev/null +++ b/app/Main.hs @@ -0,0 +1,23 @@ +module Main (main) where + +import Control.Arrow (left) +import qualified Cron +import Intro +import System.Environment (getArgs) +import System.IO (getLine) + +main :: IO () +main = do + cron <- getCron + putStrLn . showOrErr $ Cron.toProse <$> (Cron.parse =<< cron) + +getCron :: IO (Either String String) +getCron = do + args <- getArgs + case args of + [] -> Right <$> getLine + [x] -> pure $ Right x + xs -> pure $ Left ("Too many inputs or invalid option: " ++ show xs) + +showOrErr :: Either String String -> String +showOrErr = either id id . left ("Error. " ++) -- cgit v1.2.3