Add support for weak references with unlifted keys
- Dominant language
- Haskell
- Stars
- 123
- Forks
- 60
- PR merge metrics
- No merged PRs in 30d
Description
We should be able to write
```haskell
mkWeakFromUnlifted
:: (PrimUnlifted k, PrimMonad m, PrimState m ~ RealWorld)
=> k -> v -> IO () -> m (Weak v)
```
We should also be able to write a (nasty) type
```haskell
newtype WeakUnlifted a =
WeakUnlifted (Weak Any)
type role WeakUnlifted representational
```
This would allow weak references *containing* unlifted values. The GHC primops language doesn't seem to know how to express such a primitive type yet, although it's conceptually simple. We'd end up with four fundamental creation functions.
Relatedly, we should offer
```haskell
touchUnlifted
:: (PrimUnlifted a, PrimMonad m, PrimState m ~ RealWorld)
=> a -> m ()
touchUnlifted a =
primitive_ $ touch# (toUnlifted# a)
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.