1 -----------------------------------------------------------------------------
3 -- Module : System.Exit
4 -- Copyright : (c) The University of Glasgow 2001
5 -- License : BSD-style (see the file libraries/core/LICENSE)
7 -- Maintainer : libraries@haskell.org
8 -- Stability : provisional
9 -- Portability : portable
11 -- $Id: Exit.hs,v 1.1 2001/06/28 14:15:04 simonmar Exp $
13 -- Exiting the program.
15 -----------------------------------------------------------------------------
19 ExitCode(ExitSuccess,ExitFailure)
20 , exitWith -- :: ExitCode -> IO a
21 , exitFailure -- :: IO a
26 #ifdef __GLASGOW_HASKELL__
30 -- ---------------------------------------------------------------------------
33 -- `exitWith code' terminates the program, returning `code' to the
34 -- program's caller. Before it terminates, any open or semi-closed
35 -- handles are first closed.
37 exitWith :: ExitCode -> IO a
38 exitWith ExitSuccess = throw (ExitException ExitSuccess)
39 exitWith code@(ExitFailure n)
40 | n == 0 = ioException (IOError Nothing InvalidArgument "exitWith" "ExitFailure 0" Nothing)
41 | otherwise = throw (ExitException code)
44 exitFailure = exitWith (ExitFailure 1)