Safe Haskell | Safe-Inferred |
---|---|
Language | GHC2021 |
This module provides a persistant TVar in Bulter storage.
Synopsis
- data MemoryVar a
- newMemoryVar :: Serialise a => MonadIO m => Storage -> StorageAddress -> m a -> m (a, MemoryVar a)
- readMemoryVar :: MemoryVar a -> STM a
- modifyMemoryVar :: MemoryVar a -> (a -> a) -> STM ()
- stateMemoryVar :: MemoryVar a -> (a -> (b, a)) -> STM b
Documentation
newMemoryVar :: Serialise a => MonadIO m => Storage -> StorageAddress -> m a -> m (a, MemoryVar a) #
Instanciate a new MemoryVar
by providing a Storage
and a StorageAddress
readMemoryVar :: MemoryVar a -> STM a #
Read the MemoryVar
. Use it as a replacement to readTVar.
modifyMemoryVar :: MemoryVar a -> (a -> a) -> STM () #
Write into the MemoryVar
. The inner TVar
is persisted to the Butler storage.
Use it as a replacement to modifyTVar'
.
stateMemoryVar :: MemoryVar a -> (a -> (b, a)) -> STM b #
Similar to modifyMemoryVar
but returning an extra value
Use it as a replacement to stateTVar