modify

open fun <A> TVar<A>.modify(f: (A) -> A)(source)

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