arrow-core-data / arrow.core / Eval / always

always

fun <A> always(f: () -> A): Always<A>

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.core.*

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

“expensive computation” is computed every time value() is invoked.