Class Eval<A>
java.lang.Object
fj.data.Eval<A>
Eval is an abstraction over different models of evaluation.
The data constructors:
Now- the value is evaluated immediately.Later- the value is evaluated only once when it's requested (lazy evaluation).Always- the value is evaluated every time when it's requested.
Later and Always are lazy computations, while Now is eager.- Version:
- %build.number%
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <A> Eval<A> Constructs a lazy evaluation without caching.final <B> Eval<B> static <A> Eval<A> final <B> Eval<B> Alias forbind(F).static <A> Eval<A> Constructs a lazy evaluation with caching.final <B> Eval<B> static <A> Eval<A> now(A a) Constructs an eager evaluation by wrapping the given value.abstract Avalue()Evaluates the computation and return its result.
-
Constructor Details
-
Eval
public Eval()
-
-
Method Details
-
now
Constructs an eager evaluation by wrapping the given value.- Parameters:
a- the evaluated value.- Returns:
- an eval with computed value.
-
later
-
always
-
defer
-
value
Evaluates the computation and return its result. Depending on whether the current instance is lazy or eager the computation may or may not happen at this point.- Returns:
- a result of this computation.
-
map
-
flatMap
-
bind
TransformsEvalinto aEvalusing the given function that directly producesEval. Note: the computation of the given transformation is always lazy, even if it invoked for an eagerNowinstance. This computation is performed in O(1) stack space.- Parameters:
f- the transformation function.- Returns:
- a transformed evaluation.
-