acid-state-0.16.1.3: Add ACID guarantees to any serializable Haskell data structure.
Safe HaskellSafe-Inferred
LanguageHaskell2010

Data.Acid.Abstract

Synopsis

Documentation

data AcidState st Source #

State container offering full ACID (Atomicity, Consistency, Isolation and Durability) guarantees.

Atomicity
State changes are all-or-nothing. This is what you'd expect of any state variable in Haskell and AcidState doesn't change that.
Consistency
No event or set of events will break your data invariants.
Isolation
Transactions cannot interfere with each other even when issued in parallel.
Durability
Successful transaction are guaranteed to survive unexpected system shutdowns (both those caused by hardware and software).

Constructors

AcidState 

Fields

scheduleUpdate :: UpdateEvent event => AcidState (EventState event) -> event -> IO (MVar (EventResult event)) Source #

Issue an Update event and return immediately. The event is not durable before the MVar has been filled but the order of events is honored. The behavior in case of exceptions is exactly the same as for update.

If EventA is scheduled before EventB, EventA will be executed before EventB:

do scheduleUpdate acid EventA
   scheduleUpdate acid EventB
   

groupUpdates :: UpdateEvent event => AcidState (EventState event) -> [event] -> IO () Source #

Schedule multiple Update events and wait for them to be durable, but throw away their results. This is useful for importing existing datasets into an AcidState.

update :: UpdateEvent event => AcidState (EventState event) -> event -> IO (EventResult event) Source #

Issue an Update event and wait for its result. Once this call returns, you are guaranteed that the changes to the state are durable. Events may be issued in parallel.

It's a run-time error to issue events that aren't supported by the AcidState.

update' :: (UpdateEvent event, MonadIO m) => AcidState (EventState event) -> event -> m (EventResult event) Source #

Same as update but lifted into any monad capable of doing IO.

query :: QueryEvent event => AcidState (EventState event) -> event -> IO (EventResult event) Source #

Issue a Query event and wait for its result. Events may be issued in parallel.

query' :: (QueryEvent event, MonadIO m) => AcidState (EventState event) -> event -> m (EventResult event) Source #

Same as query but lifted into any monad capable of doing IO.

mkAnyState :: Typeable sub_st => sub_st st -> AnyState st Source #

downcast :: (Typeable sub, Typeable st) => AcidState st -> sub st Source #