acid-state-0.16.1.4: Add ACID guarantees to any serializable Haskell data structure.

Copyright | PublicDomain
Maintainer | lemmih@gmail.com
Portability | non-portable (uses GHC extensions)
Safe Haskell | None
Language | Haskell2010

Data.Acid.Common

Description

Common structures used by the various backends (local, memory).

Synopsis

- class IsAcidic st where
  - acidEvents :: [Event st]
- newtype Update st a = Update {
  - unUpdate :: State st a
  }
- newtype Query st a = Query {
  - unQuery :: Reader st a
  }
- liftQuery :: Query st a -> Update st a
- type EventResult ev = MethodResult ev
- type EventState ev = MethodState ev
- data Event st where
  - UpdateEvent :: forall ev. UpdateEvent ev => (ev -> Update (EventState ev) (EventResult ev)) -> MethodSerialiser ev -> Event (MethodState ev)
  - QueryEvent :: forall ev. QueryEvent ev => (ev -> Query (EventState ev) (EventResult ev)) -> MethodSerialiser ev -> Event (MethodState ev)
- class Method ev => UpdateEvent ev
- class Method ev => QueryEvent ev
- eventsToMethods :: [Event st] -> [MethodContainer st]

# Documentation

class IsAcidic st where Source #

Methods

acidEvents Source #

Arguments

:: [Event st] | List of events capable of updating or querying the state.

newtype Update st a Source #

Context monad for Update events.

Constructors

Update |

Fields

- unUpdate :: State st a

#### Instances

Instances details

MonadState st (Update st) Source # |
Instance details Defined in Data.Acid.Common Methods get :: Update st st Source # put :: st -> Update st () Source # state :: (st -> (a, st)) -> Update st a Source #
Applicative (Update st) Source # |
Instance details Defined in Data.Acid.Common Methods pure :: a -> Update st a Source # (<*>) :: Update st (a -> b) -> Update st a -> Update st b Source # liftA2 :: (a -> b -> c) -> Update st a -> Update st b -> Update st c Source # (*>) :: Update st a -> Update st b -> Update st b Source # (<*) :: Update st a -> Update st b -> Update st a Source #
Functor (Update st) Source # |
Instance details Defined in Data.Acid.Common Methods fmap :: (a -> b) -> Update st a -> Update st b Source # (<$) :: a -> Update st b -> Update st a Source #
Monad (Update st) Source # |
Instance details Defined in Data.Acid.Common Methods (>>=) :: Update st a -> (a -> Update st b) -> Update st b Source # (>>) :: Update st a -> Update st b -> Update st b Source # return :: a -> Update st a Source #

newtype Query st a Source #

Context monad for Query events.

Constructors

Query |

Fields

- unQuery :: Reader st a

#### Instances

Instances details

MonadReader st (Query st) Source # |
Instance details Defined in Data.Acid.Common Methods ask :: Query st st Source # local :: (st -> st) -> Query st a -> Query st a Source # reader :: (st -> a) -> Query st a Source #
Applicative (Query st) Source # |
Instance details Defined in Data.Acid.Common Methods pure :: a -> Query st a Source # (<*>) :: Query st (a -> b) -> Query st a -> Query st b Source # liftA2 :: (a -> b -> c) -> Query st a -> Query st b -> Query st c Source # (*>) :: Query st a -> Query st b -> Query st b Source # (<*) :: Query st a -> Query st b -> Query st a Source #
Functor (Query st) Source # |
Instance details Defined in Data.Acid.Common Methods fmap :: (a -> b) -> Query st a -> Query st b Source # (<$) :: a -> Query st b -> Query st a Source #
Monad (Query st) Source # |
Instance details Defined in Data.Acid.Common Methods (>>=) :: Query st a -> (a -> Query st b) -> Query st b Source # (>>) :: Query st a -> Query st b -> Query st b Source # return :: a -> Query st a Source #

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

Run a query in the Update Monad.

type EventResult ev = MethodResult ev Source #

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

type EventState ev = MethodState ev Source #

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 :: forall ev. UpdateEvent ev => (ev -> Update (EventState ev) (EventResult ev)) -> MethodSerialiser ev -> Event (MethodState ev) |
QueryEvent :: forall ev. QueryEvent ev => (ev -> Query (EventState ev) (EventResult ev)) -> MethodSerialiser ev -> Event (MethodState ev) |

class Method ev => UpdateEvent ev Source #

All UpdateEvents are also Methods.

class Method ev => QueryEvent ev Source #

All QueryEvents are also Methods.

eventsToMethods :: [Event st] -> [MethodContainer st] Source #