Class Eval<A>
java.lang.Object
fj.data.Eval<A>
- Direct Known Subclasses:
Eval.Always, Eval.Later, Eval.Now, Eval.TrampolineEval
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%
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static final classRepresents a lazy computation that is evaluated every time when it's requested.private static final classprivate static final classprivate static final classRepresents a lazy computation that is evaluated only once.private static final classRepresents an eager computation.private static final classprivate static classA helper abstraction that allows to perform recursive lazy transformations in O(1) stack space. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <A> Eval<A> Constructs a lazy evaluation without caching.(package private) abstract Eval.TrampolineEval<A> Transforms the current instance into a trampoline instance.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.
-
asTrampoline
Transforms the current instance into a trampoline instance.
-