|Portability||non-portable (uses GHC extensions)|
AcidState container without a transaction log. Mostly used for testing.
- class SafeCopy st => IsAcidic st where
- data AcidState st
- data Event st where
- type EventResult ev = MethodResult ev
- type EventState ev = MethodState ev
- class Method ev => UpdateEvent ev
- class Method ev => QueryEvent ev
- data Update st a
- data Query st a
- openAcidState :: IsAcidic st => st -> IO (AcidState st)
- closeAcidState :: AcidState st -> IO ()
- createCheckpoint :: SafeCopy st => AcidState st -> IO ()
- createCheckpointAndClose :: SafeCopy st => AcidState st -> IO ()
- update :: UpdateEvent event => AcidState (EventState event) -> event -> IO (EventResult event)
- scheduleUpdate :: UpdateEvent event => AcidState (EventState event) -> event -> IO (MVar (EventResult event))
- query :: QueryEvent event => AcidState (EventState event) -> event -> IO (EventResult event)
- update' :: (UpdateEvent event, MonadIO m) => AcidState (EventState event) -> event -> m (EventResult event)
- query' :: (QueryEvent event, MonadIO m) => AcidState (EventState event) -> event -> m (EventResult event)
- runQuery :: Query st a -> Update st a
State container offering full ACID (Atomicity, Consistency, Isolation and Durability) guarantees.
- State changes are all-or-nothing. This is what you'd expect of any state variable in Haskell and AcidState doesn't change that.
- No event or set of events will break your data invariants.
- Transactions cannot interfere with each other even when issued in parallel.
- Successful transaction are guaranteed to survive system failure (both hardware and software).
We distinguish between events that modify the state and those that do not.
UpdateEvents are executed in a MonadState context and have to be serialized to disk before they are considered durable.
QueryEvents are executed in a MonadReader context and obviously do not have to be serialized to disk.
Events return the same thing as Methods. The exact type of
depends on the event.
Context monad for Update events.
Context monad for Query events.
Create an AcidState given an initial value.
Close an AcidState and associated logs. Any subsequent usage of the AcidState will throw an exception.
This is a nop with the memory backend.
This is an alias for
closeAcidState when using the memory backend.
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.
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
If EventA is scheduled before EventB, EventA will be executed before EventB:
do scheduleUpdate acid EventA scheduleUpdate acid EventB
Issue a Query event and wait for its result. Events may be issued in parallel.
update but lifted into any monad capable of doing IO.
query but lifted into any monad capable of doing IO.