| ||||||||||||||||
| ||||||||||||||||
| ||||||||||||||||
| Synopsis | ||||||||||||||||
| ACID monad | ||||||||||||||||
| data Ev m t | ||||||||||||||||
| ||||||||||||||||
| type AnyEv a = forall t. (Monad (t STM), MonadTrans t) => Ev (t STM) a | ||||||||||||||||
| ACID computations that work with any state and event types. | ||||||||||||||||
| data TxControl | ||||||||||||||||
| query :: (MonadIO m, QueryEvent ev res) => ev -> m res | ||||||||||||||||
| Emit a state query and wait for the result. | ||||||||||||||||
| update :: (MonadIO m, UpdateEvent ev res) => ev -> m res | ||||||||||||||||
| Schedule an update and wait for it to complete. When this function returns, you're guaranteed the update will be persistent. | ||||||||||||||||
| type Update state = Ev (StateT state STM) | ||||||||||||||||
| type Query state = Ev (ReaderT state STM) | ||||||||||||||||
| Types | ||||||||||||||||
| type TxId = Int64 | ||||||||||||||||
| type EpochMilli = Int64 | ||||||||||||||||
| data TxConfig | ||||||||||||||||
| ||||||||||||||||
| nullTxConfig :: TxConfig | ||||||||||||||||
| data Saver | ||||||||||||||||
| ||||||||||||||||
| Misc utilities | ||||||||||||||||
| setUpdateType :: Proxy t -> Update t () | ||||||||||||||||
| Use a proxy to force the type of an update action. | ||||||||||||||||
| setQueryType :: Proxy t -> Query t () | ||||||||||||||||
| Use a proxy to force the type of a query action. | ||||||||||||||||
| asUpdate :: Update t a -> Proxy t -> Update t a | ||||||||||||||||
| Currying version of setUpdateType. | ||||||||||||||||
| asQuery :: Query t a -> Proxy t -> Query t a | ||||||||||||||||
| Currying version of setQueryType. | ||||||||||||||||
| askState :: Query st st | ||||||||||||||||
| Specialized version of ask | ||||||||||||||||
| getState :: Update st st | ||||||||||||||||
| Specialized version of get | ||||||||||||||||
| putState :: st -> Update st () | ||||||||||||||||
| Specialized version of put. | ||||||||||||||||
| liftSTM :: STM a -> AnyEv a | ||||||||||||||||
| Lift an STM action into Ev. | ||||||||||||||||
| class CatchEv m where | ||||||||||||||||
| ||||||||||||||||
| sel :: (Env -> b) -> AnyEv b | ||||||||||||||||
| Select a part of the environment. | ||||||||||||||||
| localState :: (outer -> inner) -> (inner -> outer -> outer) -> Ev (StateT inner STM) a -> Ev (StateT outer STM) a | ||||||||||||||||
Run a computation with a local environment. 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) a | ||||||||||||||||
| Run a computation with local state. | ||||||||||||||||
| runQuery :: Query st a -> Update st a | ||||||||||||||||
| Execute a Query action in the Update monad. | ||||||||||||||||
| getEventId :: Integral txId => AnyEv txId | ||||||||||||||||
| getTime :: Integral epochTime => AnyEv epochTime | ||||||||||||||||
| getEventClockTime :: AnyEv ClockTime | ||||||||||||||||
| Random numbers | ||||||||||||||||
| getRandom :: Random a => AnyEv a | ||||||||||||||||
| Get a random number. | ||||||||||||||||
| getRandomR :: Random a => (a, a) -> AnyEv a | ||||||||||||||||
| Get a random number inside the range. | ||||||||||||||||
| TH helpers | ||||||||||||||||
| inferRecordUpdaters :: Name -> Q [Dec] | ||||||||||||||||
| Infer updating functions for a record a_foo :: component -> record -> record and withFoo = localState foo a_foo. | ||||||||||||||||
| Serialization | ||||||||||||||||
| module HAppS.State.Control | ||||||||||||||||
| runTxSystem :: (Methods st, Component st) => Saver -> Proxy st -> IO (MVar TxControl) | ||||||||||||||||
| Run a transaction system | ||||||||||||||||
| shutdownSystem :: MVar TxControl -> IO () | ||||||||||||||||
| module HAppS.State.ComponentTH | ||||||||||||||||
| module HAppS.State.ComponentSystem | ||||||||||||||||
| closeTxControl :: MVar TxControl -> IO () | ||||||||||||||||
| createCheckpoint :: MVar TxControl -> IO () | ||||||||||||||||
| Unsafe things | ||||||||||||||||
| unsafeIOToEv :: IO a -> AnyEv a | ||||||||||||||||
| Produced by Haddock version 2.1.0 | ||||||||||||||||