abstract fun retry(): Nothing

Abort and retry the current transaction.

Aborts the transaction and suspends until any of the accessed TVar's changed, after which the transaction will restart. Since all other datastructures are built upon TVar's this automatically extends to those structures as well.

The main use for this is to abort once the transaction has hit an invalid state or otherwise needs to wait for changes.

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

suspend fun main() {
val result = atomically {
stm { retry() } orElse { "Alternative" }
println("Result $result")