acid-state-0.16.1.2: Add ACID guarantees to any serializable Haskell data structure.
CopyrightPublicDomain
Maintainerlemmih@gmail.com
Portabilitynon-portable (uses GHC extensions)
Safe HaskellSafe-Inferred
LanguageHaskell2010

Data.Acid.Memory.Pure

Description

AcidState container without a transaction log. Mostly used for testing.

This module consists of internal implementation details for Data.Acid.Memory. You should not normally need to import it. Call openMemoryState and thereafter use the API from Data.Acid instead.

Synopsis

Documentation

class IsAcidic st where Source #

Methods

acidEvents Source #

Arguments

:: [Event st]

List of events capable of updating or querying the state.

data AcidState st Source #

Pure state value used internally. This is not the same as AcidState from Data.Acid.

data Event st where Source #

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.

Constructors

UpdateEvent :: UpdateEvent ev => (ev -> Update (EventState ev) (EventResult ev)) -> MethodSerialiser ev -> Event (EventState ev) 
QueryEvent :: QueryEvent ev => (ev -> Query (EventState ev) (EventResult ev)) -> MethodSerialiser ev -> Event (EventState ev) 

type EventResult ev = MethodResult ev Source #

Events return the same thing as Methods. The exact type of EventResult depends on the event.

class Method ev => UpdateEvent ev Source #

All UpdateEvents are also Methods.

class Method ev => QueryEvent ev Source #

All QueryEvents are also Methods.

data Update st a Source #

Context monad for Update events.

Instances

Instances details
MonadState st (Update st) Source # 
Instance details

Defined in Data.Acid.Common

Methods

get :: Update st st

put :: st -> Update st ()

state :: (st -> (a, st)) -> Update st a

Applicative (Update st) Source # 
Instance details

Defined in Data.Acid.Common

Methods

pure :: a -> Update st a

(<*>) :: Update st (a -> b) -> Update st a -> Update st b

liftA2 :: (a -> b -> c) -> Update st a -> Update st b -> Update st c

(*>) :: Update st a -> Update st b -> Update st b

(<*) :: Update st a -> Update st b -> Update st a

Functor (Update st) Source # 
Instance details

Defined in Data.Acid.Common

Methods

fmap :: (a -> b) -> Update st a -> Update st b

(<$) :: a -> Update st b -> Update st a

Monad (Update st) Source # 
Instance details

Defined in Data.Acid.Common

Methods

(>>=) :: Update st a -> (a -> Update st b) -> Update st b

(>>) :: Update st a -> Update st b -> Update st b

return :: a -> Update st a

data Query st a Source #

Context monad for Query events.

Instances

Instances details
MonadReader st (Query st) Source # 
Instance details

Defined in Data.Acid.Common

Methods

ask :: Query st st

local :: (st -> st) -> Query st a -> Query st a

reader :: (st -> a) -> Query st a

Applicative (Query st) Source # 
Instance details

Defined in Data.Acid.Common

Methods

pure :: a -> Query st a

(<*>) :: Query st (a -> b) -> Query st a -> Query st b

liftA2 :: (a -> b -> c) -> Query st a -> Query st b -> Query st c

(*>) :: Query st a -> Query st b -> Query st b

(<*) :: Query st a -> Query st b -> Query st a

Functor (Query st) Source # 
Instance details

Defined in Data.Acid.Common

Methods

fmap :: (a -> b) -> Query st a -> Query st b

(<$) :: a -> Query st b -> Query st a

Monad (Query st) Source # 
Instance details

Defined in Data.Acid.Common

Methods

(>>=) :: Query st a -> (a -> Query st b) -> Query st b

(>>) :: Query st a -> Query st b -> Query st b

return :: a -> Query st a

openAcidState Source #

Arguments

:: IsAcidic st 
=> st

Initial state value.

-> AcidState st 

Create an AcidState given an initial value.

update :: UpdateEvent event => AcidState (EventState event) -> event -> (AcidState (EventState event), 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 => AcidState (EventState event) -> event -> AcidState (EventState event) Source #

Same as update but ignoring the event result.

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

Issue a Query event and wait for its result.

liftQuery :: Query st a -> Update st a Source #

Run a query in the Update Monad.

runUpdate :: Update s r -> s -> (r, s) Source #

Execute the Update monad in a pure environment.

runQuery :: Query s r -> s -> r Source #

Execute the Query monad in a pure environment.