summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Gamari <ben@smart-cactus.org>2023-03-23 21:56:55 -0400
committerMarge Bot <ben+marge-bot@smart-cactus.org>2023-05-16 07:28:15 -0400
commit41ecfc34770dd83765095c4f20682b1ce8207730 (patch)
tree6e4065b55b7e6ff6f7907f19af4ef1fa56cdc9e9
parentbdb93cd28f4a40e9a9f28b0976ca8fa4f250cad2 (diff)
downloadhaskell-41ecfc34770dd83765095c4f20682b1ce8207730.tar.gz
base: Export {get,set}ExceptionFinalizer from System.Mem.Weak
As proposed in CLC Proposal #126 [1]. [1]: https://github.com/haskell/core-libraries-committee/issues/126
-rw-r--r--libraries/base/System/Mem/Weak.hs8
-rw-r--r--libraries/base/changelog.md2
2 files changed, 10 insertions, 0 deletions
diff --git a/libraries/base/System/Mem/Weak.hs b/libraries/base/System/Mem/Weak.hs
index d5fd14cf50..9792a429cd 100644
--- a/libraries/base/System/Mem/Weak.hs
+++ b/libraries/base/System/Mem/Weak.hs
@@ -64,6 +64,14 @@ module System.Mem.Weak (
mkWeakPair,
-- replaceFinaliser
+ -- * Handling exceptions
+ -- | When an exception is thrown by a finalizer called by the
+ -- garbage collector, GHC calls a global handler which can be set with
+ -- 'setFinalizerExceptionHandler'. Note that any exceptions thrown by
+ -- this handler will be ignored.
+ setFinalizerExceptionHandler,
+ getFinalizerExceptionHandler,
+
-- * A precise semantics
-- $precise
diff --git a/libraries/base/changelog.md b/libraries/base/changelog.md
index 26e7f36d5f..c11265c0c1 100644
--- a/libraries/base/changelog.md
+++ b/libraries/base/changelog.md
@@ -14,6 +14,8 @@
* Add `Type.Reflection.decTypeRep`, `Data.Typeable.decT` and `Data.Typeable.hdecT` equality decisions functions.
([CLC proposal #98](https://github.com/haskell/core-libraries-committee/issues/98))
* Add `Data.Functor.unzip` ([CLC proposal #88](https://github.com/haskell/core-libraries-committee/issues/88))
+ * Add `System.Mem.Weak.{get,set}FinalizerExceptionHandler`, which allows the user to set the global handler invoked by when a `Weak` pointer finalizer throws an exception. ([CLC proposal #126](https://github.com/haskell/core-libraries-committee/issues/126))
+ * Add `System.Mem.Weak.printToStderrFinalizerExceptionHandler`, which can be used with `setFinalizerExceptionHandler` to print exceptions thrown by finalizers to `stderr`. ([CLC proposal #126](https://github.com/haskell/core-libraries-committee/issues/126))
* Implement more members of `instance Foldable (Compose f g)` explicitly.
([CLC proposal #57](https://github.com/haskell/core-libraries-committee/issues/57))
* Add `Eq` and `Ord` instances for `SSymbol`, `SChar`, and `SNat`.