Skip to content
Snippets Groups Projects
Script.hs 469 B
Newer Older
module System.Script
  ( syntax
  , try
  , warn ) where
import Control.Monad.IO.Class (MonadIO(..))
import System.Exit (die)
import System.Environment (getProgName)
import System.IO (hPutStrLn, stderr)
import Text.Printf (printf)

syntax :: String -> IO ()
syntax s = do
  this <- getProgName
  die $ printf "Syntax: %s %s" this s
try :: MonadIO m => m (Either String a) -> m a
try = (>>= either (liftIO . die) pure)

warn :: String -> IO ()
warn = hPutStrLn stderr