Documentation

Hale.STM.Control.Monad.STM

Result of an STM transaction step.

Instances For

    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)$$

      Equations
      Instances For
        @[inline]
        def Control.Monad.STM.orElse {α : Type} (a b : STM α) :
        STM α

        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
        Instances For
          @[inline]

          Check a condition; retry if false. $$\text{check}(p) = \text{if } p \text{ then pure () else retry}$$

          Equations
          Instances For
            partial def Control.Monad.atomically {α : Type} (action : STM α) :
            IO α

            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)$$