From 41ecfc34770dd83765095c4f20682b1ce8207730 Mon Sep 17 00:00:00 2001 From: Ben Gamari Date: Thu, 23 Mar 2023 21:56:55 -0400 Subject: 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 --- libraries/base/System/Mem/Weak.hs | 8 ++++++++ libraries/base/changelog.md | 2 ++ 2 files changed, 10 insertions(+) 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`. -- cgit v1.2.1