summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Hengel <sol@typeful.net>2014-04-21 11:34:38 +0800
committerHerbert Valerio Riedel <hvr@gnu.org>2014-04-21 13:28:59 +0200
commitc4ea79c71ad01287bfbdaafa78bdf195988411e2 (patch)
tree1c041edaefbf16a2a5d1457f94013d153bd74f55
parent31dd5e5db965fa9ed30ac5b58514668f92843c01 (diff)
downloadhaskell-wip/T9016.tar.gz
Add System.Exit.die (re #9016)wip/T9016
The original proposal discussion can be found at http://thread.gmane.org/gmane.comp.lang.haskell.libraries/20872
-rw-r--r--libraries/base/System/Exit.hs7
-rw-r--r--libraries/base/changelog.md2
2 files changed, 9 insertions, 0 deletions
diff --git a/libraries/base/System/Exit.hs b/libraries/base/System/Exit.hs
index a3059fcf9b..4f6eba629c 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 a72e4e6871..c561165024 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*