[commit: ghc] master: Add displayException method to Exception (#9822) (3222b7a)
git at git.haskell.org
git at git.haskell.org
Fri Nov 21 22:30:53 UTC 2014
Repository : ssh://git@git.haskell.org/ghc
On branch : master
Link : http://ghc.haskell.org/trac/ghc/changeset/3222b7ae347be092bdd414f7b43bee18861b0e1e/ghc
>---------------------------------------------------------------
commit 3222b7ae347be092bdd414f7b43bee18861b0e1e
Author: Michael Snoyman <michael at snoyman.com>
Date: Fri Nov 21 23:26:09 2014 +0100
Add displayException method to Exception (#9822)
Defaults to using `show` to prevent any breakage of existing code. Also
provide a custom implementation for `SomeException` which uses the
underlying exception's `displayException`.
Differential Revision: https://phabricator.haskell.org/D517
>---------------------------------------------------------------
3222b7ae347be092bdd414f7b43bee18861b0e1e
libraries/base/GHC/Exception.hs | 9 +++++++++
libraries/base/changelog.md | 2 ++
2 files changed, 11 insertions(+)
diff --git a/libraries/base/GHC/Exception.hs b/libraries/base/GHC/Exception.hs
index 7a7c8c2..e2b7149 100644
--- a/libraries/base/GHC/Exception.hs
+++ b/libraries/base/GHC/Exception.hs
@@ -140,9 +140,18 @@ class (Typeable e, Show e) => Exception e where
toException = SomeException
fromException (SomeException e) = cast e
+ -- | Render this exception value in a human-friendly manner.
+ --
+ -- Default implementation: @'show'@.
+ --
+ -- /Since: 4.8.0.0/
+ displayException :: e -> String
+ displayException = show
+
instance Exception SomeException where
toException se = se
fromException = Just
+ displayException (SomeException e) = displayException e
-- | Throw an exception. Exceptions may be thrown from purely
-- functional code, but may only be caught within the 'IO' monad.
diff --git a/libraries/base/changelog.md b/libraries/base/changelog.md
index 3e110a7..a5ae8ea 100644
--- a/libraries/base/changelog.md
+++ b/libraries/base/changelog.md
@@ -104,6 +104,8 @@
* Add `fillBytes` to `Foreign.Marshal.Utils`.
+ * Add new `displayException` method to `Exception` typeclass. (#9822)
+
## 4.7.0.1 *Jul 2014*
* Bundled with GHC 7.8.3
More information about the ghc-commits
mailing list