API Reference¶
Generated Dokka API docs can be built with:
./gradlew dokkaGeneratePublicationHtml
Need¶
Need<A> represents a value of type A that may not have been evaluated yet.
valueforces evaluation and returns the cached result.maptransforms the eventual value without forcing it immediately.flatMapsequences another lazy computation.zipcombines thisNeedwith another and returns a lazyPair.zipLeftevaluates this value first, then returns the right-hand value.zipRightevaluates both values and keeps the left-hand value.
The companion object provides constructors and helpers:
nowwraps an already available value.unitis a cachedNeed<Unit>.applydelays a strict computation.deferdelays a computation that already returnsNeed.zipoverloads combine two to fourNeedvalues with a function.recursivesupports self-referential lazy definitions.buildcreates a memoized nullable resolver and caches only non-null values.buildNonNullcreates a memoized resolver for non-null values.
Delay¶
Delay<A> abstracts over a representation that can wrap and unwrap Need<A>.
strictevaluates wrapped values immediately and stores them asA.needkeeps values inNeed.recursivebuilds recursive delayed values usingNeed.recursive.forceunwraps, evaluates one layer, and wraps the evaluated value again.
Behavioral Notes¶
Equality and hash codes force the compared Need values because they are based on value.
Concurrent forcing may duplicate work. The final cached result converges, but Need does not
serialize the first evaluation across threads.