butler-0.0.1.0: At your service.
Safe HaskellSafe-Inferred
LanguageGHC2021

Butler.Core.Memory

Description

This module provides a persistant TVar in Bulter storage.

Synopsis

Documentation

data MemoryVar a #

The MemoryVar that wraps the TVar. The TVar content must be an instance of Serialise.

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