1 -----------------------------------------------------------------------------
3 -- Module : System.Exit
4 -- Copyright : (c) The University of Glasgow 2001
5 -- License : BSD-style (see the file libraries/base/LICENSE)
7 -- Maintainer : libraries@haskell.org
8 -- Stability : provisional
9 -- Portability : portable
11 -- Exiting the program.
13 -----------------------------------------------------------------------------
17 ExitCode(ExitSuccess,ExitFailure)
18 , exitWith -- :: ExitCode -> IO a
19 , exitFailure -- :: IO a
24 #ifdef __GLASGOW_HASKELL__
39 -- ---------------------------------------------------------------------------
42 -- `exitWith code' terminates the program, returning `code' to the
43 -- program's caller. Before it terminates, any open or semi-closed
44 -- handles are first closed.
47 exitWith :: ExitCode -> IO a
48 exitWith ExitSuccess = throw (ExitException ExitSuccess)
49 exitWith code@(ExitFailure n)
50 | n /= 0 = throw (ExitException code)
51 #ifdef __GLASGOW_HASKELL__
52 | otherwise = ioError (IOError Nothing InvalidArgument "exitWith" "ExitFailure 0" Nothing)
54 #endif /* ! __NHC__ */
57 exitFailure = exitWith (ExitFailure 1)