System/Exit.hs (original) (raw)

module System.Exit ( ExitCode(ExitSuccess,ExitFailure) , exitWith
, exitFailure
, exitSuccess
) where

import Prelude

#ifdef GLASGOW_HASKELL import GHC.IO import GHC.IO.Exception #endif

#ifdef HUGS import Hugs.Prelude (ExitCode(..)) import Control.Exception.Base #endif

#ifdef NHC import System ( ExitCode(..) , exitWith ) #endif

#ifndef NHC exitWith :: ExitCode -> IO a exitWith ExitSuccess = throwIO ExitSuccess exitWith code@(ExitFailure n) | n /= 0 = throwIO code #ifdef GLASGOW_HASKELL | otherwise = ioError (IOError Nothing InvalidArgument "exitWith" "ExitFailure 0" Nothing Nothing) #endif #endif /* ! NHC */

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

exitSuccess :: IO a exitSuccess = exitWith ExitSuccess