83a5c3690035ab5268b17b0b6a68e29ff05c6f13
[packages/haskell2010.git] / System / Exit.hs
1 #if __GLASGOW_HASKELL__ >= 701
2 {-# LANGUAGE Safe #-}
3 #endif
4
5 module System.Exit (
6 ExitCode(ExitSuccess,ExitFailure)
7 , exitWith -- :: ExitCode -> IO a
8 , exitFailure -- :: IO a
9 , exitSuccess -- :: IO a
10 ) where
11 import "base" System.Exit hiding (exitWith)
12 import qualified "base" System.Exit as Base
13
14 -- SDM: use the Haskell 98 docs for exitWith, since the base docs talk
15 -- about exceptions which aren't in Haskell 2010.
16
17 -- SDM: removed:
18 -- Before the program terminates, any open or semi-closed handles are
19 -- first closed.
20
21 -- SDM: removed:
22 -- If a program terminates as a result of calling @error@\indextt{error} or
23 -- because its value is otherwise determined to be "\bot"\index{"\bot"}, then it
24 -- is treated identically to the computation @exitFailure@. Otherwise, if any
25 -- program "p" terminates without calling @exitWith@ explicitly, it is treated
26 -- identically to the computation
27 -- \bprog
28 -- @(@"p"@ >> exitWith ExitSuccess) `catch` \ _ -> exitFailure@
29 -- \eprog
30
31 {- |
32 Computation @'exitWith' code@ terminates the program, returning @code@
33 to the program's caller.
34 The caller may interpret the return code as it wishes, but the program
35 should return 'ExitSuccess' to mean normal completion, and
36 @'ExitFailure' n@ to mean that the program encountered a problem from
37 which it could not recover. The value 'exitFailure' is equal to
38 @'exitWith' ('ExitFailure' exitfail)@, where @exitfail@ is
39 implementation-dependent. 'exitWith' bypasses the error handling in
40 the I/O monad and cannot be intercepted by 'catch' from the @Prelude@.
41 -}
42 exitWith :: ExitCode -> IO a
43 exitWith = Base.exitWith