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