arrow-core-data / arrow.core / Eval / later


fun <A> later(f: () -> A): Later<A>

Creates an Eval instance from a function deferring it’s evaluation until .value() is invoked memoizing the computed value.


f -

is a function or computation that will be called only once when .value() is invoked for the first time.

import arrow.core.*

fun main() {
  val lazyEvaled = Eval.later { "expensive computation" }

“expensive computation” is only computed once since the results are memoized and multiple calls to value() will just return the cached value.

Do you like Arrow?

Arrow Org