|Maintainer||Bas van Dijk <firstname.lastname@example.org>|
A mutable variable in the region monad that should provide a safer
replacement for an
IORef because you can't use it outside the region in
which it was created (unless you explicitly duplicate it).
- data RegionRef r α
- pureDup :: RegionRef (RegionT cs (RegionT ps ppr)) α -> RegionRef (RegionT ps ppr) α
- newRegionRef :: MonadIO pr => α -> RegionT s pr (RegionRef (RegionT s pr) α)
- readRegionRef :: (ParentOf pr cr, MonadIO cr) => RegionRef pr α -> cr α
- writeRegionRef :: (ParentOf pr cr, MonadIO cr) => RegionRef pr α -> α -> cr ()
- modifyRegionRef :: (ParentOf pr cr, MonadIO cr) => RegionRef pr α -> (α -> α) -> cr ()
- atomicModifyRegionRef :: (ParentOf pr cr, MonadIO cr) => RegionRef pr α -> (α -> (α, β)) -> cr β
A mutable variable storing a value of type
α which can only be used
r's children or
r's parent when you duplicate it using
Transform the region type
r of the regional reference to
r's parent so
that it can be used in that region.
Yield a regional computation that returns a new regional reference that stores the given value.
Note that the reference is parameterized by the same region in which it was created. This ensures you can never use this reference outside that region and it allows you to use this reference in a child region of that region
Read the value of the given regional reference.
Write a new value into the given regional reference.
Mutate the contents of the given regional reference using the given function.
Atomically modifies the contents of the given regional reference using the given function.
This function is useful for using a regional reference in a safe way in a
multithreaded program. If you only have one regional reference, then using
atomicModifyRegionRef to access and modify it will prevent race conditions.