STMModule
PackageAxial
Summary
| Name | Signature | Synopsis |
|---|---|---|
| retry | STM.retry | Signals that the current branch should retry once observed state changes. |
| orElse | STM.orElse left right | Tries the left branch and falls back to the right branch when the left branch retries. |
| atomically | STM.atomically transaction | Executes an STM transaction atomically within a flow while preserving retry/orElse coordination. |
Signals that the current branch should retry once observed state changes.
Returns
STM<'T>
Tries the left branch and falls back to the right branch when the left branch retries.
Parameters
| Name | Type | Description |
|---|---|---|
| left | STM<'T> | The primary STM transaction to attempt. |
| right | STM<'T> | The fallback STM transaction to run if the first one retries. |
Returns
STM<'T>
Executes an STM transaction atomically within a flow while preserving retry/orElse coordination.
Parameters
| Name | Type | Description |
|---|---|---|
| transaction | STM<'T> | The STM transaction to execute. |
Returns
Flow<'env, 'none, 'T>
Verification Examples
let transfer (fromAcc: TRef<int>) (toAcc: TRef<int>) amount =
stm {
let! bal = TRef.get fromAcc
if bal < amount then do! STM.retry
do! TRef.set (bal - amount) fromAcc
do! TRef.update (fun b -> b + amount) toAcc
}
let flow = STM.atomically (transfer acc1 acc2 100)
