Safe Haskell  None 

Language  Haskell2010 
 data Projection state event = Projection {
 projectionSeed :: state
 projectionEventHandler :: state > event > state
 latestProjection :: Foldable t => Projection state event > t event > state
 allProjections :: Projection state event > [event] > [state]
 getLatestProjection :: Monad m => EventStore serialized m > Projection proj serialized > UUID > m (proj, EventVersion)
 getLatestGlobalProjection :: Monad m => GloballyOrderedEventStore serialized m > Projection proj (ProjectionEvent serialized) > Maybe (proj, SequenceNumber) > m (proj, SequenceNumber)
 serializedProjection :: Projection state event > Serializer event serialized > Projection state serialized
Documentation
data Projection state event Source #
A Projection
is a piece of state
that is constructed only from
event
s. A Projection is how you reconstruct event sourced state from the
ordered stream of events that constitute that state. The "seed" of a
Projection is the initial state before any events are applied. The event
handler for a projection is the function that actually modifies state based
on the given event.
Projection  

latestProjection :: Foldable t => Projection state event > t event > state Source #
Computes the latest state of a Projection
from some events.
allProjections :: Projection state event > [event] > [state] Source #
Given a list of events, produce all the Projections that were ever
produced. Just a scanl
using projectionEventHandler
. This function is
useful for testing Projection
s; you can easily assert that all the states
of a Projection are valid given a list of events.
getLatestProjection :: Monad m => EventStore serialized m > Projection proj serialized > UUID > m (proj, EventVersion) Source #
Gets the latest projection from a store by using getEvents
and then
applying the events using the Projection's event handler.
getLatestGlobalProjection :: Monad m => GloballyOrderedEventStore serialized m > Projection proj (ProjectionEvent serialized) > Maybe (proj, SequenceNumber) > m (proj, SequenceNumber) Source #
Gets globally ordered events from the event store and builds a
Projection
based on ProjectionEvent
. Optionally accepts the current
projection state as an argument.
serializedProjection :: Projection state event > Serializer event serialized > Projection state serialized Source #
Use a Serializer
to wrap a Projection
with event type event
so it
uses the serialized
type.