The STM monad. Wraps BaseIO actions that execute under the global STM lock. $$\text{STM}(\alpha) = \text{BaseIO}(\text{STMResult}(\alpha))$$
Equations
Instances For
@[implicit_reducible]
Equations
- One or more equations did not get rendered due to their size.
@[implicit_reducible]
Equations
- One or more equations did not get rendered due to their size.
@[inline]
Signal retry: abort this transaction and wait for state changes. $$\text{retry} : \text{STM}(\alpha)$$
Instances For
@[inline]
Try the first transaction; if it retries, try the second. $$\text{orElse}(a, b) = \begin{cases} a & \text{if } a \text{ succeeds} \\ b & \text{if } a \text{ retries} \end{cases}$$
Equations
- a.orElse b = do let result ← a match result with | Control.Monad.STMResult.success v => pure (Control.Monad.STMResult.success v) | Control.Monad.STMResult.retry => b
Instances For
Run an STM transaction atomically. Blocks until the transaction succeeds (i.e., does not retry).
Uses a global Std.Mutex to serialize all transactions. If the transaction
signals retry, the lock is released and the thread sleeps briefly before
retrying.
$$\text{atomically} : \text{STM}(\alpha) \to \text{IO}(\alpha)$$