Wolfgang Jeltsch pushed to branch wip/jeltsch/system-io-uncovering at Glasgow Haskell Compiler / GHC

Commits:

4 changed files:

Changes:

  • libraries/base/src/GHC/ResponseFile.hs
    ... ... @@ -23,12 +23,12 @@ module GHC.ResponseFile (
    23 23
     import GHC.Internal.Control.Exception
    
    24 24
     import GHC.Internal.Data.Foldable      (Foldable(..))
    
    25 25
     import GHC.Internal.Base
    
    26
    -import GHC.Internal.Unicode        (isSpace)
    
    26
    +import GHC.Internal.Unicode            (isSpace)
    
    27 27
     import GHC.Internal.Data.List          (filter, unlines, concat, reverse)
    
    28 28
     import GHC.Internal.Text.Show          (show)
    
    29 29
     import GHC.Internal.System.Environment (getArgs)
    
    30
    -import GHC.Internal.System.Exit        (exitFailure)
    
    31 30
     import GHC.Internal.System.IO
    
    31
    +import System.Exit                     (exitFailure)
    
    32 32
     
    
    33 33
     {-|
    
    34 34
     Like 'getArgs', but can also read arguments supplied via response files.
    

  • libraries/base/src/System/Exit.hs
    1
    -{-# LANGUAGE Safe #-}
    
    1
    +{-# LANGUAGE Trustworthy #-}
    
    2 2
     
    
    3 3
     -- |
    
    4 4
     --
    
    ... ... @@ -21,4 +21,59 @@ module System.Exit
    21 21
          die
    
    22 22
          ) where
    
    23 23
     
    
    24
    -import GHC.Internal.System.Exit
    \ No newline at end of file
    24
    +import GHC.Internal.System.IO
    
    25
    +
    
    26
    +import GHC.Internal.Base
    
    27
    +import GHC.Internal.IO
    
    28
    +import GHC.Internal.IO.Exception
    
    29
    +
    
    30
    +-- ---------------------------------------------------------------------------
    
    31
    +-- exitWith
    
    32
    +
    
    33
    +-- | Computation 'exitWith' @code@ throws 'ExitCode' @code@.
    
    34
    +-- Normally this terminates the program, returning @code@ to the
    
    35
    +-- program's caller.
    
    36
    +--
    
    37
    +-- On program termination, the standard 'Handle's 'stdout' and
    
    38
    +-- 'stderr' are flushed automatically; any other buffered 'Handle's
    
    39
    +-- need to be flushed manually, otherwise the buffered data will be
    
    40
    +-- discarded.
    
    41
    +--
    
    42
    +-- A program that fails in any other way is treated as if it had
    
    43
    +-- called 'exitFailure'.
    
    44
    +-- A program that terminates successfully without calling 'exitWith'
    
    45
    +-- explicitly is treated as if it had called 'exitWith' 'ExitSuccess'.
    
    46
    +--
    
    47
    +-- As an 'ExitCode' is an 'Control.Exception.Exception', it can be
    
    48
    +-- caught using the functions of "Control.Exception".  This means that
    
    49
    +-- cleanup computations added with 'GHC.Internal.Control.Exception.bracket' (from
    
    50
    +-- "Control.Exception") are also executed properly on 'exitWith'.
    
    51
    +--
    
    52
    +-- Note: in GHC, 'exitWith' should be called from the main program
    
    53
    +-- thread in order to exit the process.  When called from another
    
    54
    +-- thread, 'exitWith' will throw an 'ExitCode' as normal, but the
    
    55
    +-- exception will not cause the process itself to exit.
    
    56
    +--
    
    57
    +exitWith :: ExitCode -> IO a
    
    58
    +exitWith ExitSuccess = throwIO ExitSuccess
    
    59
    +exitWith code@(ExitFailure n)
    
    60
    +  | n /= 0 = throwIO code
    
    61
    +  | otherwise = ioError (IOError Nothing InvalidArgument "exitWith" "ExitFailure 0" Nothing Nothing)
    
    62
    +
    
    63
    +-- | The computation 'exitFailure' is equivalent to
    
    64
    +-- 'exitWith' @(@'ExitFailure' /exitfail/@)@,
    
    65
    +-- where /exitfail/ is implementation-dependent.
    
    66
    +exitFailure :: IO a
    
    67
    +exitFailure = exitWith (ExitFailure 1)
    
    68
    +
    
    69
    +-- | The computation 'exitSuccess' is equivalent to
    
    70
    +-- 'exitWith' 'ExitSuccess', It terminates the program
    
    71
    +-- successfully.
    
    72
    +exitSuccess :: IO a
    
    73
    +exitSuccess = exitWith ExitSuccess
    
    74
    +
    
    75
    +-- | Write given error message to `stderr` and terminate with `exitFailure`.
    
    76
    +--
    
    77
    +-- @since base-4.8.0.0
    
    78
    +die :: String -> IO a
    
    79
    +die err = hPutStrLn stderr err >> exitFailure

  • libraries/ghc-internal/ghc-internal.cabal.in
    ... ... @@ -322,7 +322,6 @@ Library
    322 322
             GHC.Internal.Numeric.Natural
    
    323 323
             GHC.Internal.System.Environment
    
    324 324
             GHC.Internal.System.Environment.Blank
    
    325
    -        GHC.Internal.System.Exit
    
    326 325
             GHC.Internal.System.IO
    
    327 326
             GHC.Internal.System.IO.Error
    
    328 327
             GHC.Internal.System.IO.OS
    

  • libraries/ghc-internal/src/GHC/Internal/System/Exit.hs deleted
    1
    -{-# LANGUAGE Trustworthy #-}
    
    2
    -
    
    3
    ------------------------------------------------------------------------------
    
    4
    --- |
    
    5
    --- Module      :  GHC.Internal.System.Exit
    
    6
    --- Copyright   :  (c) The University of Glasgow 2001
    
    7
    --- License     :  BSD-style (see the file libraries/base/LICENSE)
    
    8
    ---
    
    9
    --- Maintainer  :  libraries@haskell.org
    
    10
    --- Stability   :  provisional
    
    11
    --- Portability :  portable
    
    12
    ---
    
    13
    --- Exiting the program.
    
    14
    ---
    
    15
    ------------------------------------------------------------------------------
    
    16
    -
    
    17
    -module GHC.Internal.System.Exit
    
    18
    -    (
    
    19
    -      ExitCode(ExitSuccess,ExitFailure)
    
    20
    -    , exitWith
    
    21
    -    , exitFailure
    
    22
    -    , exitSuccess
    
    23
    -    , die
    
    24
    -  ) where
    
    25
    -
    
    26
    -import GHC.Internal.System.IO
    
    27
    -
    
    28
    -import GHC.Internal.Base
    
    29
    -import GHC.Internal.IO
    
    30
    -import GHC.Internal.IO.Exception
    
    31
    -
    
    32
    --- ---------------------------------------------------------------------------
    
    33
    --- exitWith
    
    34
    -
    
    35
    --- | Computation 'exitWith' @code@ throws 'ExitCode' @code@.
    
    36
    --- Normally this terminates the program, returning @code@ to the
    
    37
    --- program's caller.
    
    38
    ---
    
    39
    --- On program termination, the standard 'Handle's 'stdout' and
    
    40
    --- 'stderr' are flushed automatically; any other buffered 'Handle's
    
    41
    --- need to be flushed manually, otherwise the buffered data will be
    
    42
    --- discarded.
    
    43
    ---
    
    44
    --- A program that fails in any other way is treated as if it had
    
    45
    --- called 'exitFailure'.
    
    46
    --- A program that terminates successfully without calling 'exitWith'
    
    47
    --- explicitly is treated as if it had called 'exitWith' 'ExitSuccess'.
    
    48
    ---
    
    49
    --- As an 'ExitCode' is an 'Control.Exception.Exception', it can be
    
    50
    --- caught using the functions of "Control.Exception".  This means that
    
    51
    --- cleanup computations added with 'GHC.Internal.Control.Exception.bracket' (from
    
    52
    --- "Control.Exception") are also executed properly on 'exitWith'.
    
    53
    ---
    
    54
    --- Note: in GHC, 'exitWith' should be called from the main program
    
    55
    --- thread in order to exit the process.  When called from another
    
    56
    --- thread, 'exitWith' will throw an 'ExitCode' as normal, but the
    
    57
    --- exception will not cause the process itself to exit.
    
    58
    ---
    
    59
    -exitWith :: ExitCode -> IO a
    
    60
    -exitWith ExitSuccess = throwIO ExitSuccess
    
    61
    -exitWith code@(ExitFailure n)
    
    62
    -  | n /= 0 = throwIO code
    
    63
    -  | otherwise = ioError (IOError Nothing InvalidArgument "exitWith" "ExitFailure 0" Nothing Nothing)
    
    64
    -
    
    65
    --- | The computation 'exitFailure' is equivalent to
    
    66
    --- 'exitWith' @(@'ExitFailure' /exitfail/@)@,
    
    67
    --- where /exitfail/ is implementation-dependent.
    
    68
    -exitFailure :: IO a
    
    69
    -exitFailure = exitWith (ExitFailure 1)
    
    70
    -
    
    71
    --- | The computation 'exitSuccess' is equivalent to
    
    72
    --- 'exitWith' 'ExitSuccess', It terminates the program
    
    73
    --- successfully.
    
    74
    -exitSuccess :: IO a
    
    75
    -exitSuccess = exitWith ExitSuccess
    
    76
    -
    
    77
    --- | Write given error message to `stderr` and terminate with `exitFailure`.
    
    78
    ---
    
    79
    --- @since base-4.8.0.0
    
    80
    -die :: String -> IO a
    
    81
    -die err = hPutStrLn stderr err >> exitFailure