cqrs-0.3.0: Command-Query Responsibility Segregation



Run transactions against event stores.



data TransactionT e m a Source

Transaction monad transformer.

getAggregateRoot :: (Default a, Event e, Typeable a, Typeable e, Aggregate a, Eventable a e) => GUID a -> TransactionT e IO (AggregateRef a e, a)Source

Get aggregate root.

publishEvent :: (MonadIO m, Event e, Eventable a e) => AggregateRef a e -> e -> TransactionT e m ()Source

Publish event for an aggregate root.

retrieveEvents :: forall e. Event e => Int -> Int -> (e -> IO ()) -> TransactionT e IO ()Source

Retrieve a range of events, invoking a callback function for each event. For example,

 retrieveEvents 10 20 $ \e -> do
   putStrLn $ "Event: " ++ show e

would print all events between logical time 20 (inclusive) and logical time 30 (not inclusive). Logical time starts at 1. It is NOT an error to provide bounds for which there are no events.

runTransactionT :: (Typeable e, Event e) => EventStore -> TransactionT e IO c -> IO cSource

Run transaction against an event store.