- data Ev m t
- type AnyEv a = forall t. (Monad (t STM), MonadTrans t) => Ev (t STM) a
- data TxControl
- query :: (MonadIO m, QueryEvent ev res) => ev -> m res
- update :: (MonadIO m, UpdateEvent ev res) => ev -> m res
- type Update state = Ev (StateT state STM)
- type Query state = Ev (ReaderT state STM)
- type TxId = Int64
- type EpochMilli = Int64
- data Saver
- setUpdateType :: Proxy t -> Update t ()
- proxyUpdate :: Update t b -> Proxy t -> Update t b
- setQueryType :: Proxy t -> Query t ()
- proxyQuery :: Query t b -> Proxy t -> Query t b
- asUpdate :: Update t a -> Proxy t -> Update t a
- asQuery :: Query t a -> Proxy t -> Query t a
- askState :: Query st st
- getState :: Update st st
- putState :: st -> Update st ()
- liftSTM :: STM a -> AnyEv a
- class CatchEv m where
- sel :: (Env -> b) -> AnyEv b
- localState :: (outer -> inner) -> (inner -> outer -> outer) -> Ev (StateT inner STM) a -> Ev (StateT outer STM) a
- localStateReader :: (outer -> inner) -> Ev (ReaderT inner STM) a -> Ev (ReaderT outer STM) a
- runQuery :: Query st a -> Update st a
- getEventId :: Integral txId => AnyEv txId
- getTime :: Integral epochTime => AnyEv epochTime
- getEventClockTime :: AnyEv ClockTime
- getEventStream :: IO (IO EventItem)
- data EventItem = EventItem {
- eventContext :: TxContext
- eventData :: Dynamic
- getRandom :: Random a => AnyEv a
- getRandomR :: Random a => (a, a) -> AnyEv a
- inferRecordUpdaters :: Name -> Q [Dec]
- module Happstack.Data.Serialize
- module Happstack.Data.SerializeTH
- module Happstack.State.Control
- module Happstack.State.ComponentTH
- module Happstack.State.ComponentSystem
- runTxSystem :: (Methods st, Component st) => Saver -> Proxy st -> IO (MVar TxControl)
- createCheckpoint :: MVar TxControl -> IO ()
- shutdownSystem :: MVar TxControl -> IO ()
- unsafeIOToEv :: IO a -> AnyEv a
ACID monad
Monad for ACID event handlers.
type AnyEv a = forall t. (Monad (t STM), MonadTrans t) => Ev (t STM) aSource
ACID computations that work with any state and event types.
query :: (MonadIO m, QueryEvent ev res) => ev -> m resSource
Emit a state query and wait for the result.
update :: (MonadIO m, UpdateEvent ev res) => ev -> m resSource
Schedule an update and wait for it to complete. When this function returns, you're guaranteed the update will be persistent.
Types
type EpochMilli = Int64Source
Misc utilities
setUpdateType :: Proxy t -> Update t ()Source
Use a proxy to force the type of an update action.
proxyUpdate :: Update t b -> Proxy t -> Update t bSource
Forces the type of the proxy and update to match
setQueryType :: Proxy t -> Query t ()Source
Use a proxy to force the type of a query action.
proxyQuery :: Query t b -> Proxy t -> Query t bSource
Forces the type of proxy and query to match
localState :: (outer -> inner) -> (inner -> outer -> outer) -> Ev (StateT inner STM) a -> Ev (StateT outer STM) aSource
Run a computation with local state. Changes to state will be visible to outside.
localStateReader :: (outer -> inner) -> Ev (ReaderT inner STM) a -> Ev (ReaderT outer STM) aSource
Run a computation with local state.
getEventId :: Integral txId => AnyEv txIdSource
Random numbers
getRandomR :: Random a => (a, a) -> AnyEv aSource
Get a random number inside the range.
TH helpers
inferRecordUpdaters :: Name -> Q [Dec]Source
Infer updating functions for a record. Given a data declaration
of data Foo = Foo {bar :: String, baz :: Int}
then $(inferRecordUpdaters ''Foo)
will define functions a_bar :: String -> Foo -> Foo
, withBar :: Update String a -> Update Foo a
,
etc. that can be used as convenience updaters.
Serialization
module Happstack.Data.Serialize
module Happstack.Data.SerializeTH
module Happstack.State.Control
module Happstack.State.ComponentTH
runTxSystem :: (Methods st, Component st) => Saver -> Proxy st -> IO (MVar TxControl)Source
Run the MACID system without multimaster support and with the given Saver.
Unsafe things
unsafeIOToEv :: IO a -> AnyEv aSource