always

inline fun <A> always(crossinline f: () -> A): Eval.Always<A>(source)

Creates an Eval instance from a function deferring it's evaluation until .value() is invoked recomputing each time .value() is invoked.

Parameters

f

is a function or computation that will be called every time .value() is invoked.

import arrow.eval.*

fun main() {
//sampleStart
val alwaysEvaled = Eval.always { "expensive computation" }
println(alwaysEvaled.value())
//sampleEnd
}

"expensive computation" is computed every time value() is invoked.