Newer
Older
module System.Script
( syntax
, try
, warn ) where
Alice Brenon
committed
Alice Brenon
committed
import Control.Monad.IO.Class (MonadIO(..))
Alice Brenon
committed
import System.Exit (die)
import System.Environment (getProgName)
import System.IO (hPutStrLn, stderr)
Alice Brenon
committed
import Text.Printf (printf)
syntax :: String -> IO ()
syntax s = do
this <- getProgName
die $ printf "Syntax: %s %s" this s
Alice Brenon
committed
try :: MonadIO m => m (Either String a) -> m a
try = (>>= either (liftIO . die) pure)
warn :: String -> IO ()
warn = hPutStrLn stderr