|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 -> AcidState st
- update :: UpdateEvent event => AcidState (EventState event) -> event -> (AcidState (EventState event), EventResult event)
- update_ :: UpdateEvent event => AcidState (EventState event) -> event -> AcidState (EventState event)
- query :: QueryEvent event => AcidState (EventState event) -> event -> EventResult event
- liftQuery :: Query st a -> Update st a
- runUpdate :: Update s r -> s -> (r, s)
- runQuery :: Query s r -> s -> r
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.
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 but ignoring the event result.
Issue a Query event and wait for its result.