//arrow-fx-stm/arrow.fx.stm/stm

stm

common inline fun <A> stm(noinline f: STM.() -> A): STM.() -> A

Helper to create stm blocks that can be run with STM.orElse

import arrow.fx.stm.atomically
import arrow.fx.stm.stm

suspend fun main() {
  //sampleStart
  val i = 4
  val result = atomically {
    stm {
      if (i == 4) retry()
      "Not 4"
    } orElse { "4" }
  }
  //sampleEnd
  println("Result $result")
}

Equal to suspend just with an STM receiver.

Do you like Arrow?

Arrow Org
<