static <A, B> F<A, B> fix(F<F<A, B>, F<A, B>> f, F<F0<B>, B> delay) { return new F<A, B>() { final F<A, B> rec = f.f(this); @Override public B f(A a) { return delay.f(() -> rec.f(a)); } }; }
/** * OOP style 'withers': */ public final Request withPath(String newPath) { return Requests.setPath(newPath).f(this); }
public final Request withBody(String newBody) { // if there is no body field (eg. GET, DELETE) then the original request is // returned (no modification): return Requests.setBody(newBody).f(this); }
@Override public C _3() { return fc.f(unit()); } @Override
@Override public B _2() { return fb.f(unit()); } @Override
@Override public B _2() { return fb.f(unit()); } @Override
@Override public C _3() { return fc.f(unit()); } @Override
@Override public F$ _6() { return ff.f(unit()); } };
@Override public A _1() { return fa.f(unit()); } @Override
@Override public B _2() { return fb.f(unit()); } @Override
@Override public A _1() { return fa.f(unit()); } @Override
@Override public B _2() { return fb.f(unit()); } @Override
/** * Returns <code>false</code> if no value or returns the result of the application of the given * function to the value. * * @param f The predicate function to test on this projection's value. * @return <code>false</code> if no value or returns the result of the application of the given * function to the value. */ public boolean exists(final F<A, Boolean> f) { return e.isLeft() && f.f(value()); }
/** * Returns the 1-product projection over the fourth element. * * @return the 1-product projection over the fourth element. */ public final P1<D> _4_() { return F1Functions.lazy(P5.<A, B, C, D, E>__4()).f(this); }
/** * Performs function application within a P1 (applicative functor pattern). * * @param cf The P1 function to apply. * @return A new P1 after applying the given P1 function to the first argument. */ public final <B> P1<B> apply(final P1<F<A, B>> cf) { P1<A> self = this; return cf.bind(f -> map_(f).f(self)); }
/** * Returns the 1-product projection over the third element. * * @return the 1-product projection over the third element. */ public final P1<C> _3_() { return F1Functions.lazy(P8.<A, B, C, D, E, F, G, H>__3()).f(this); }
/** * Returns the 1-product projection over the sixth element. * * @return the 1-product projection over the sixth element. */ public final P1<F> _6_() { return F1Functions.lazy(P7.<A, B, C, D, E, F, G>__6()).f(this); }
/** * Maps a function across a Zipper in parallel. * * @param za A Zipper to map across in parallel. * @param f A function to map across the given Zipper. * @return A promise of a new Zipper with the given function applied to each element. */ public <A, B> Promise<Zipper<B>> parMap(final Zipper<A> za, final F<A, B> f) { return parMap(za.rights(), f) .apply(promise(f).f(za.focus()).apply(parMap(za.lefts(), f).fmap(curry(Zipper.zipper())))); }