shithub: MicroHs

ref: 6deb7698801b1d644c9d3a8bc94cd22adc8490f5
dir: /lib/System/Exit.hs/

View raw version
module System.Exit(
  ExitCode(..),
  exitWith,
  exitFailure,
  exitSuccess,
  die,
  ) where
import Prelude
import Control.Exception
import System.IO

data ExitCode = ExitSuccess | ExitFailure Int
  deriving (Show)

-- XXX This needs work
exitWith :: forall a . ExitCode -> IO a
exitWith e = throwIO (Exn (show e))

exitFailure :: forall a . IO a
exitFailure = exitWith (ExitFailure 1)

exitSuccess :: forall a . IO a
exitSuccess = exitWith ExitSuccess

die :: forall a . String -> IO a
die err = hPutStrLn stderr err >> exitFailure