[commit: ghc] wip/T9016: Add System.Exit.die (re #9016) (c4ea79c)
git at git.haskell.org
git at git.haskell.org
Mon Apr 21 11:42:35 UTC 2014
Repository : ssh://git@git.haskell.org/ghc
On branch : wip/T9016
Link : http://ghc.haskell.org/trac/ghc/changeset/c4ea79c71ad01287bfbdaafa78bdf195988411e2/ghc
>---------------------------------------------------------------
commit c4ea79c71ad01287bfbdaafa78bdf195988411e2
Author: Simon Hengel <sol at typeful.net>
Date: Mon Apr 21 11:34:38 2014 +0800
Add System.Exit.die (re #9016)
The original proposal discussion can be found at
http://thread.gmane.org/gmane.comp.lang.haskell.libraries/20872
>---------------------------------------------------------------
c4ea79c71ad01287bfbdaafa78bdf195988411e2
libraries/base/System/Exit.hs | 7 +++++++
libraries/base/changelog.md | 2 ++
2 files changed, 9 insertions(+)
diff --git a/libraries/base/System/Exit.hs b/libraries/base/System/Exit.hs
index a3059fc..4f6eba6 100644
--- a/libraries/base/System/Exit.hs
+++ b/libraries/base/System/Exit.hs
@@ -20,9 +20,11 @@ module System.Exit
, exitWith
, exitFailure
, exitSuccess
+ , die
) where
import Prelude
+import System.IO
import GHC.IO
import GHC.IO.Exception
@@ -74,3 +76,8 @@ exitFailure = exitWith (ExitFailure 1)
exitSuccess :: IO a
exitSuccess = exitWith ExitSuccess
+-- | Write given error message to `stderr` and terminate with `exitFailure`.
+--
+-- /Since: 4.7.1.0/
+die :: String -> IO ()
+die err = hPutStrLn stderr err >> exitFailure
diff --git a/libraries/base/changelog.md b/libraries/base/changelog.md
index a72e4e6..c561165 100644
--- a/libraries/base/changelog.md
+++ b/libraries/base/changelog.md
@@ -8,6 +8,8 @@
* Add `Data.List.sortOn` sorting function
+ * Add `System.Exit.die`
+
* Weaken RealFloat constraints on some `Data.Complex` functions
## 4.7.0.0 *Apr 2014*
More information about the ghc-commits
mailing list