public D _4() { return P4.this._4(); } };
public D _4() { return P4.this._4(); } };
public A _3() { return p._4(); } }));
public D _4() { return P4.this._4(); } };
public X _4() { return f.f(P4.this._4()); } };
/** * Creates a {@link P8} by adding the given element to the current {@link P4} * * @param el the element to append * @return A {@link P8} containing the original {@link P4} with the extra element added at the end */ public final <E, F, G, H> P8<A, B, C, D, E, F, G, H> append(P4<E, F, G, H> el) { return P.p(_1(), _2(), _3(), _4(), el._1(), el._2(), el._3(), el._4()); }
/** * Creates a {@link P5} by adding the given element to the current {@link P4} * * @param el the element to append * @return A {@link P5} containing the original {@link P4} with the extra element added at the end */ public final <E> P5<A, B, C, D, E> append(E el) { return P.p(_1(), _2(), _3(), _4(), el); }
/** * Creates a {@link P6} by adding the given element to the current {@link P4} * * @param el the element to append * @return A {@link P6} containing the original {@link P4} with the extra element added at the end */ public final <E, F> P6<A, B, C, D, E, F> append(P2<E, F> el) { return P.p(_1(), _2(), _3(), _4(), el._1(), el._2()); }
/** * Creates a {@link P6} by adding the given element to the current {@link P2} * * @param el the element to append * @return A {@link P6} containing the original {@link P2} with the extra element added at the end */ public final <C, D, E, F> P6<A, B, C, D, E, F> append(P4<C, D, E, F> el) { return P.p(_1(), _2(), el._1(), el._2(), el._3(), el._4()); }
/** * An equal instance for a product-4. * * @param ea Equality across the first element of the product. * @param eb Equality across the second element of the product. * @param ec Equality across the third element of the product. * @param ed Equality across the fourth element of the product. * @return An equal instance for a product-4. */ public static <A, B, C, D> Equal<P4<A, B, C, D>> p4Equal(final Equal<A> ea, final Equal<B> eb, final Equal<C> ec, final Equal<D> ed) { Definition<A> eaDef = ea.def; Definition<B> ebDef = eb.def; Definition<C> ecDef = ec.def; Definition<D> edDef = ed.def; return equalDef((p1, p2) -> eaDef.equal(p1._1(), p2._1()) && ebDef.equal(p1._2(), p2._2()) && ecDef.equal(p1._3(), p2._3()) && edDef.equal(p1._4(), p2._4())); }
/** * Creates a {@link P7} by adding the given element to the current {@link P3} * * @param el the element to append * @return A {@link P7} containing the original {@link P3} with the extra element added at the end */ public final <D, E, F, G> P7<A, B, C, D, E, F, G> append(P4<D, E, F, G> el) { return P.p(_1(), _2(), _3(), el._1(), el._2(), el._3(), el._4()); }
/** * Creates a {@link P7} by adding the given element to the current {@link P4} * * @param el the element to append * @return A {@link P7} containing the original {@link P4} with the extra element added at the end */ public final <E, F, G> P7<A, B, C, D, E, F, G> append(P3<E, F, G> el) { return P.p(_1(), _2(), _3(), _4(), el._1(), el._2(), el._3()); }
/** * A hash instance for a product-4. * * @param ha A hash for the first element of the product. * @param hb A hash for the second element of the product. * @param hc A hash for the third element of the product. * @param hd A hash for the fourth element of the product. * @return A hash instance for a product-4. */ public static <A, B, C, D> Hash<P4<A, B, C, D>> p4Hash(final Hash<A> ha, final Hash<B> hb, final Hash<C> hc, final Hash<D> hd) { return hash(p4 -> { final int p = 419; int r = 239; r = p * r + ha.hash(p4._1()); r = p * r + hb.hash(p4._2()); r = p * r + hc.hash(p4._3()); r = p * r + hd.hash(p4._4()); return r; }); }
/** * A show instance for the {@link P4 tuple-4} type. * * @param sa Show for the first element of the tuple. * @param sb Show for the second element of the tuple. * @param sc Show for the third element of the tuple. * @param sd Show for the fourth element of the tuple. * @return A show instance for the {@link P4 tuple-4} type. */ public static <A, B, C, D> Show<P4<A, B, C, D>> p4Show(final Show<A> sa, final Show<B> sb, final Show<C> sc, final Show<D> sd) { return show(p -> cons('(', p(sa.show(p._1()))).snoc(',').append(sb.show(p._2())).snoc(',') .append(sc.show(p._3())).snoc(',').append(sd.show(p._4())).snoc(')')); }
/** * Promotes this function to zip two TreeZippers, applying the function lock-step over both zippers in all directions. * The structure of the resulting TreeZipper is the structural intersection of the two TreeZippers. * * @return A function that zips two TreeZippers with this function. */ public static <A, B, C> F2<TreeZipper<A>, TreeZipper<B>, TreeZipper<C>> zipTreeZipperM(final F2<A, B, C> f) { return (ta, tb) -> { final F2<Stream<Tree<A>>, Stream<Tree<B>>, Stream<Tree<C>>> sf = zipStreamM(treeM(f)); final F2<Stream<P3<Stream<Tree<A>>, A, Stream<Tree<A>>>>, Stream<P3<Stream<Tree<B>>, B, Stream<Tree<B>>>>, Stream<P3<Stream<Tree<C>>, C, Stream<Tree<C>>>>> pf = zipStreamM((pa, pb) -> p(zipStreamM(treeM(f)).f(pa._1(), pb._1()), f.f(pa._2(), pb._2()), zipStreamM(treeM(f)).f(pa._3(), pb._3()))); return treeZipper(treeM(f).f(ta.p()._1(), tb.p()._1()), sf.f(ta.lefts(), tb.lefts()), sf.f(ta.rights(), tb.rights()), pf.f(ta.p()._4(), tb.p()._4())); }; }
/** * Maps a function across a TreeZipper in parallel. * * @param za A TreeZipper to map across in parallel. * @param f A function to map across the given TreeZipper. * @return A promise of a new TreeZipper with the given function applied to each element of the tree. */ public <A, B> Promise<TreeZipper<B>> parMap(final TreeZipper<A> za, final F<A, B> f) { final F<Tree<A>, Tree<B>> tf = Tree.<A, B>fmap_().f(f); final P4<Tree<A>, Stream<Tree<A>>, Stream<Tree<A>>, Stream<P3<Stream<Tree<A>>, A, Stream<Tree<A>>>>> p = za.p(); return mapM(p._4(), p3 -> parMap(p3._3(), tf).apply(promise(f).f(p3._2()).apply( parMap(p3._1(), tf).fmap(P.p3())))).apply(parMap(za.rights(), tf).apply( parMap(za.lefts(), tf).apply(parMap(p._1(), f).fmap(TreeZipper.treeZipper())))); }