//arrow-fx-stm/arrow.fx.stm/STM/modify
common open fun <A> TVar<A>.modify(f: (A) -> A)
Modify the value of a TVar
import arrow.fx.stm.TVar
import arrow.fx.stm.atomically
suspend fun main() {
//sampleStart
val tvar = TVar.new(10)
val result = atomically {
tvar.modify { it * 2 }
}
//sampleEnd
println(result)
}
modify(f) = write(f(read()))
Do you like Arrow?
✖