public abstract class Trampoline<A>
extends java.lang.Object
Constructor and Description |
---|
Trampoline() |
Modifier and Type | Method and Description |
---|---|
<B> Trampoline<B> |
apply(Trampoline<F<A,B>> lf)
Performs function application within a Trampoline (applicative functor pattern).
|
static <A,B> F<F<A,Trampoline<B>>,F<Trampoline<A>,Trampoline<B>>> |
bind_() |
abstract <B> Trampoline<B> |
bind(F<A,Trampoline<B>> f)
Binds the given continuation to the result of this trampoline.
|
<B,C> Trampoline<C> |
bind(Trampoline<B> lb,
F<A,F<B,C>> f)
Binds the given function across the result of this Trampoline and the given Trampoline.
|
protected abstract <R> R |
fold(F<fj.control.Trampoline.Normal<A>,R> n,
F<fj.control.Trampoline.Codense<A>,R> gs) |
static <A,B,C> F<Trampoline<A>,F<Trampoline<B>,Trampoline<C>>> |
liftM2(F<A,F<B,C>> f)
Promotes the given function of arity-2 to a function on Trampolines.
|
static <A,B> F<F<A,B>,F<Trampoline<A>,Trampoline<B>>> |
map_() |
<B> Trampoline<B> |
map(F<A,B> f)
Maps the given function across the result of this trampoline.
|
static <A> F<A,Trampoline<A>> |
pure() |
static <A> Trampoline<A> |
pure(A a)
Constructs a pure computation that results in the given value.
|
static <A> F<Trampoline<A>,Either<P1<Trampoline<A>>,A>> |
resume_() |
abstract Either<P1<Trampoline<A>>,A> |
resume()
Runs a single step of this computation.
|
A |
run()
Runs this computation all the way to the end, in constant stack.
|
static <A> F<P1<Trampoline<A>>,Trampoline<A>> |
suspend_() |
static <A> Trampoline<A> |
suspend(P1<Trampoline<A>> a)
Suspends the given computation in a thunk.
|
<B,C> Trampoline<C> |
zipWith(Trampoline<B> b,
F2<A,B,C> f)
Combines two trampolines so they run cooperatively.
|
public static <A> F<A,Trampoline<A>> pure()
public static <A> Trampoline<A> pure(A a)
a
- The value of the result.public static <A> Trampoline<A> suspend(P1<Trampoline<A>> a)
a
- A trampoline suspended in a thunk.public static <A> F<P1<Trampoline<A>>,Trampoline<A>> suspend_()
protected abstract <R> R fold(F<fj.control.Trampoline.Normal<A>,R> n, F<fj.control.Trampoline.Codense<A>,R> gs)
public abstract <B> Trampoline<B> bind(F<A,Trampoline<B>> f)
f
- A function that constructs a trampoline from the result of this trampoline.public final <B> Trampoline<B> map(F<A,B> f)
f
- A function that gets applied to the result of this trampoline.public static <A,B> F<F<A,Trampoline<B>>,F<Trampoline<A>,Trampoline<B>>> bind_()
public static <A,B> F<F<A,B>,F<Trampoline<A>,Trampoline<B>>> map_()
public static <A> F<Trampoline<A>,Either<P1<Trampoline<A>>,A>> resume_()
public abstract Either<P1<Trampoline<A>>,A> resume()
public final A run()
public final <B> Trampoline<B> apply(Trampoline<F<A,B>> lf)
lf
- A Trampoline resulting in the function to apply.public final <B,C> Trampoline<C> bind(Trampoline<B> lb, F<A,F<B,C>> f)
lb
- A given Trampoline to bind the given function with.f
- The function to combine the results of this Trampoline and the given Trampoline.public static <A,B,C> F<Trampoline<A>,F<Trampoline<B>,Trampoline<C>>> liftM2(F<A,F<B,C>> f)
f
- The function to promote to a function on Trampolines.public final <B,C> Trampoline<C> zipWith(Trampoline<B> b, F2<A,B,C> f)
b
- Another trampoline to combine with this trampoline.f
- A function to combine the results of the two trampolines.