diff options
author | bit <mutantlemon@gmail.com> | 2021-04-23 15:25:43 -0400 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2021-05-03 19:49:32 -0400 |
commit | 3a2f2475f9cbf9c7acde6d794a2780ded492983b (patch) | |
tree | 2e6b6c521405da91a8b22f6b477561ac6492400c | |
parent | 8d6b25254e7cb881e06054ce175ed3d6ef97eedb (diff) | |
download | haskell-3a2f2475f9cbf9c7acde6d794a2780ded492983b.tar.gz |
Update documentation of 'Weak'
-rw-r--r-- | libraries/base/GHC/Weak.hs | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/libraries/base/GHC/Weak.hs b/libraries/base/GHC/Weak.hs index 9ec05456c2..5044d8f8aa 100644 --- a/libraries/base/GHC/Weak.hs +++ b/libraries/base/GHC/Weak.hs @@ -78,14 +78,13 @@ finalizer running earlier than you expected. This is not a problem for caches and memo tables where early finalization is benign. Finalizers /can/ be used reliably for types that are created explicitly -and have identity, such as @IORef@ and @MVar@. However, to place a -finalizer on one of these types, you should use the specific operation -provided for that type, e.g. @mkWeakIORef@ and @addMVarFinalizer@ -respectively (the non-uniformity is accidental). These operations -attach the finalizer to the primitive object inside the box -(e.g. @MutVar#@ in the case of @IORef@), because attaching the -finalizer to the box itself fails when the outer box is optimised away -by the compiler. +and have identity, such as @IORef@, @MVar@, and @TVar@. However, to +place a finalizer on one of these types, you should use the specific +operation provided for that type, e.g. @mkWeakIORef@, @mkWeakMVar@ and +@mkWeakTVar@ respectively. These operations attach the finalizer to +the primitive object inside the box (e.g. @MutVar#@ in the case of +@IORef@), because attaching the finalizer to the box itself fails when +the outer box is optimised away by the compiler. -} data Weak v = Weak (Weak# v) |