add unofficial/undocumented function:
mkWeakIORef :: IORef a -> IO () -> IO (Weak (IORef a))
for weak pointers to IORefs. This avoids some of the problems with
inlining disturbing the semantics of mkWeak by making the weak key
point to the primitive MutVar instead of the box.
, readIORef
, writeIORef
+ , mkWeakIORef
+
, IOArray -- instance of: Eq
, newIOArray
, boundsIOArray
)
import PrelST
import PrelArr
+import PrelWeak
import PrelGHC
import PrelHandle
import PrelErr
readIORef (IORef var) = stToIO (readVar var)
writeIORef (IORef var) v = stToIO (writeVar var v)
#endif
+
+mkWeakIORef :: IORef a -> IO () -> IO (Weak (IORef a))
+mkWeakIORef r@(IORef (MutableVar r#)) f = IO $ \s ->
+ case mkWeak# r# r f s of (# s1, w #) -> (# s1, Weak w #)
\end{code}
\begin{code}