Class Tuple5<_1,_2,_3,_4,_5>
- java.lang.Object
-
- com.jnape.palatable.lambda.adt.hlist.HList
-
- com.jnape.palatable.lambda.adt.hlist.HList.HCons<_1,Tuple4<_2,_3,_4,_5>>
-
- com.jnape.palatable.lambda.adt.hlist.Tuple5<_1,_2,_3,_4,_5>
-
- Type Parameters:
_1
- The first slot element type_2
- The second slot element type_3
- The third slot element type_4
- The fourth slot element type_5
- The fifth slot element type
- All Implemented Interfaces:
Product2<_1,_2>
,Product3<_1,_2,_3>
,Product4<_1,_2,_3,_4>
,Product5<_1,_2,_3,_4,_5>
,Applicative<_5,Tuple5<_1,_2,_3,_4,?>>
,Bifunctor<_4,_5,Tuple5<_1,_2,_3,?,?>>
,BoundedBifunctor<_4,_5,java.lang.Object,java.lang.Object,Tuple5<_1,_2,_3,?,?>>
,Functor<_5,Tuple5<_1,_2,_3,_4,?>>
,Monad<_5,Tuple5<_1,_2,_3,_4,?>>
,MonadRec<_5,Tuple5<_1,_2,_3,_4,?>>
,Traversable<_5,Tuple5<_1,_2,_3,_4,?>>
,java.util.Map.Entry<_1,_2>
public class Tuple5<_1,_2,_3,_4,_5> extends HList.HCons<_1,Tuple4<_2,_3,_4,_5>> implements Product5<_1,_2,_3,_4,_5>, MonadRec<_5,Tuple5<_1,_2,_3,_4,?>>, Bifunctor<_4,_5,Tuple5<_1,_2,_3,?,?>>, Traversable<_5,Tuple5<_1,_2,_3,_4,?>>
A 5-element tuple product type, implemented as a specialized HList. Supports random access.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.jnape.palatable.lambda.adt.hlist.HList
HList.HCons<Head,Tail extends HList>, HList.HNil
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description _1
_1()
Retrieve the first element._2
_2()
Retrieve the second element._3
_3()
Retrieve the third element._4
_4()
Retrieve the fourth element._5
_5()
Retrieve the fifth element.<_4Prime,_5Prime>
Tuple5<_1,_2,_3,_4Prime,_5Prime>biMap(Fn1<? super _4,? extends _4Prime> lFn, Fn1<? super _5,? extends _5Prime> rFn)
Dually map covariantly over both the left and right parameters.<_4Prime> Tuple5<_1,_2,_3,_4Prime,_5>
biMapL(Fn1<? super _4,? extends _4Prime> fn)
Covariantly map over the left parameter.<_5Prime> Tuple5<_1,_2,_3,_4,_5Prime>
biMapR(Fn1<? super _5,? extends _5Prime> fn)
Covariantly map over the right parameter.<_0> Tuple6<_0,_1,_2,_3,_4,_5>
cons(_0 _0)
Cons an element onto the front of this HList.<_5Prime> Tuple5<_1,_2,_3,_4,_5Prime>
discardL(Applicative<_5Prime,Tuple5<_1,_2,_3,_4,?>> appB)
Sequence both thisApplicative
andappB
, discarding thisApplicative's
result and returningappB
.<_5Prime> Tuple5<_1,_2,_3,_4,_5>
discardR(Applicative<_5Prime,Tuple5<_1,_2,_3,_4,?>> appB)
Sequence both thisApplicative
andappB
, discardingappB's
result and returning thisApplicative
.static <A> Tuple5<A,A,A,A,A>
fill(A a)
Given a value of typeA
, produced an instance of this tuple with each slot set to that value.<_5Prime> Tuple5<_1,_2,_3,_4,_5Prime>
flatMap(Fn1<? super _5,? extends Monad<_5Prime,Tuple5<_1,_2,_3,_4,?>>> f)
Chain dependent computations that may continue or short-circuit based on previous results.<_5Prime> Tuple5<_1,_2,_3,_4,_5Prime>
fmap(Fn1<? super _5,? extends _5Prime> fn)
Covariantly transmute this functor's parameter using the given mapping function.static <A> Maybe<Tuple5<A,A,A,A,A>>
fromIterable(java.lang.Iterable<A> as)
Tuple4<_1,_2,_3,_4>
init()
Tuple5<_2,_1,_3,_4,_5>
invert()
Rotate the first two slots of this product.<_5Prime> Lazy<Tuple5<_1,_2,_3,_4,_5Prime>>
lazyZip(Lazy<? extends Applicative<Fn1<? super _5,? extends _5Prime>,Tuple5<_1,_2,_3,_4,?>>> lazyAppFn)
Given alazy
instance of this applicative over a mapping function, "zip" the two instances together using whatever application semantics the current applicative supports.<_5Prime> Tuple5<_1,_2,_3,_4,_5Prime>
pure(_5Prime _5Prime)
Lift the valueb
into this applicative functor.static <_1,_2,_3,_4>
Pure<Tuple5<_1,_2,_3,_4,?>>pureTuple(_1 _1, _2 _2, _3 _3, _4 _4)
Tuple5<_2,_3,_1,_4,_5>
rotateL3()
Rotate the first three values of this product one slot to the left.Tuple5<_2,_3,_4,_1,_5>
rotateL4()
Rotate the first four values of this product one slot to the left.Tuple5<_2,_3,_4,_5,_1>
rotateL5()
Rotate the first five values of this product one slot to the left.Tuple5<_3,_1,_2,_4,_5>
rotateR3()
Rotate the first three values of this product one slot to the right.Tuple5<_4,_1,_2,_3,_5>
rotateR4()
Rotate the first four values of this product one slot to the right.Tuple5<_5,_1,_2,_3,_4>
rotateR5()
Rotate the first five values of this product one slot to the right.<_6> Tuple6<_1,_2,_3,_4,_5,_6>
snoc(_6 _6)
Snoc an element onto the back of thisTuple5
.<_5Prime> Tuple5<_1,_2,_3,_4,_5Prime>
trampolineM(Fn1<? super _5,? extends MonadRec<RecursiveResult<_5,_5Prime>,Tuple5<_1,_2,_3,_4,?>>> fn)
Given some operation yielding aRecursiveResult
inside thisMonadRec
, internally trampoline the operation until it yields atermination
instruction.<_5Prime,App extends Applicative<?,App>,TravB extends Traversable<_5Prime,Tuple5<_1,_2,_3,_4,?>>,AppTrav extends Applicative<TravB,App>>
AppTravtraverse(Fn1<? super _5,? extends Applicative<_5Prime,App>> fn, Fn1<? super TravB,? extends AppTrav> pure)
Applyfn
to each element of this traversable from left to right, and collapse the results into a single resulting applicative, potentially with the assistance of the applicative's pure function.<_5Prime> Tuple5<_1,_2,_3,_4,_5Prime>
zip(Applicative<Fn1<? super _5,? extends _5Prime>,Tuple5<_1,_2,_3,_4,?>> appFn)
Given another instance of this applicative over a mapping function, "zip" the two instances together using whatever application semantics the current applicative supports.-
Methods inherited from class com.jnape.palatable.lambda.adt.hlist.HList.HCons
equals, hashCode, head, tail
-
Methods inherited from class com.jnape.palatable.lambda.adt.hlist.HList
cons, nil, singletonHList, toString, tuple, tuple, tuple, tuple, tuple, tuple, tuple
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
-
-
-
Method Detail
-
cons
public <_0> Tuple6<_0,_1,_2,_3,_4,_5> cons(_0 _0)
Cons an element onto the front of this HList.
-
snoc
public <_6> Tuple6<_1,_2,_3,_4,_5,_6> snoc(_6 _6)
Snoc an element onto the back of thisTuple5
.- Type Parameters:
_6
- the new last element type- Parameters:
_6
- the new last element- Returns:
- the new
Tuple6
-
_1
public _1 _1()
Retrieve the first element.
-
_2
public _2 _2()
Retrieve the second element.
-
_3
public _3 _3()
Retrieve the third element.
-
_4
public _4 _4()
Retrieve the fourth element.
-
_5
public _5 _5()
Retrieve the fifth element.
-
rotateL5
public Tuple5<_2,_3,_4,_5,_1> rotateL5()
Rotate the first five values of this product one slot to the left.
-
rotateR5
public Tuple5<_5,_1,_2,_3,_4> rotateR5()
Rotate the first five values of this product one slot to the right.
-
rotateL4
public Tuple5<_2,_3,_4,_1,_5> rotateL4()
Rotate the first four values of this product one slot to the left.
-
rotateR4
public Tuple5<_4,_1,_2,_3,_5> rotateR4()
Rotate the first four values of this product one slot to the right.
-
rotateL3
public Tuple5<_2,_3,_1,_4,_5> rotateL3()
Rotate the first three values of this product one slot to the left.
-
rotateR3
public Tuple5<_3,_1,_2,_4,_5> rotateR3()
Rotate the first three values of this product one slot to the right.
-
fmap
public <_5Prime> Tuple5<_1,_2,_3,_4,_5Prime> fmap(Fn1<? super _5,? extends _5Prime> fn)
Covariantly transmute this functor's parameter using the given mapping function. Generally this method is specialized to return an instance of the class implementing Functor.- Specified by:
fmap
in interfaceApplicative<_1,_2>
- Specified by:
fmap
in interfaceFunctor<_1,_2>
- Specified by:
fmap
in interfaceMonad<_1,_2>
- Specified by:
fmap
in interfaceMonadRec<_1,_2>
- Specified by:
fmap
in interfaceTraversable<_1,_2>
- Type Parameters:
_5Prime
- the new parameter type- Parameters:
fn
- the mapping function- Returns:
- a functor over B (the new parameter type)
-
biMapL
public <_4Prime> Tuple5<_1,_2,_3,_4Prime,_5> biMapL(Fn1<? super _4,? extends _4Prime> fn)
Covariantly map over the left parameter.- Specified by:
biMapL
in interfaceBifunctor<_1,_2,_3>
- Specified by:
biMapL
in interfaceBoundedBifunctor<_1,_2,_3,_4,_5>
- Type Parameters:
_4Prime
- the new left parameter type- Parameters:
fn
- the mapping function- Returns:
- a bifunctor over C (the new left parameter) and B (the same right parameter)
-
biMapR
public <_5Prime> Tuple5<_1,_2,_3,_4,_5Prime> biMapR(Fn1<? super _5,? extends _5Prime> fn)
Covariantly map over the right parameter. For all bifunctors that are also functors, it should hold thatbiMapR(f) == fmap(f)
.- Specified by:
biMapR
in interfaceBifunctor<_1,_2,_3>
- Specified by:
biMapR
in interfaceBoundedBifunctor<_1,_2,_3,_4,_5>
- Type Parameters:
_5Prime
- the new right parameter type- Parameters:
fn
- the mapping function- Returns:
- a bifunctor over A (the same left parameter) and C (the new right parameter)
-
biMap
public <_4Prime,_5Prime> Tuple5<_1,_2,_3,_4Prime,_5Prime> biMap(Fn1<? super _4,? extends _4Prime> lFn, Fn1<? super _5,? extends _5Prime> rFn)
Dually map covariantly over both the left and right parameters. This is isomorphic tobiMapL(lFn).biMapR(rFn)
.- Specified by:
biMap
in interfaceBifunctor<_1,_2,_3>
- Specified by:
biMap
in interfaceBoundedBifunctor<_1,_2,_3,_4,_5>
- Type Parameters:
_4Prime
- the new left parameter type_5Prime
- the new right parameter type- Parameters:
lFn
- the left parameter mapping functionrFn
- the right parameter mapping function- Returns:
- a bifunctor over C (the new left parameter type) and D (the new right parameter type)
-
pure
public <_5Prime> Tuple5<_1,_2,_3,_4,_5Prime> pure(_5Prime _5Prime)
Lift the valueb
into this applicative functor.- Specified by:
pure
in interfaceApplicative<_1,_2>
- Specified by:
pure
in interfaceMonad<_1,_2>
- Specified by:
pure
in interfaceMonadRec<_1,_2>
- Type Parameters:
_5Prime
- the type of the returned applicative's parameter- Parameters:
_5Prime
- the value- Returns:
- an instance of this applicative over b
-
zip
public <_5Prime> Tuple5<_1,_2,_3,_4,_5Prime> zip(Applicative<Fn1<? super _5,? extends _5Prime>,Tuple5<_1,_2,_3,_4,?>> appFn)
Given another instance of this applicative over a mapping function, "zip" the two instances together using whatever application semantics the current applicative supports.
-
lazyZip
public <_5Prime> Lazy<Tuple5<_1,_2,_3,_4,_5Prime>> lazyZip(Lazy<? extends Applicative<Fn1<? super _5,? extends _5Prime>,Tuple5<_1,_2,_3,_4,?>>> lazyAppFn)
Given alazy
instance of this applicative over a mapping function, "zip" the two instances together using whatever application semantics the current applicative supports. This is useful for applicatives that support lazy evaluation and early termination.- Specified by:
lazyZip
in interfaceApplicative<_1,_2>
- Specified by:
lazyZip
in interfaceMonad<_1,_2>
- Specified by:
lazyZip
in interfaceMonadRec<_1,_2>
- Type Parameters:
_5Prime
- the resulting applicative parameter type- Parameters:
lazyAppFn
- the lazy other applicative instance- Returns:
- the mapped applicative
- See Also:
Maybe
,Either
-
discardL
public <_5Prime> Tuple5<_1,_2,_3,_4,_5Prime> discardL(Applicative<_5Prime,Tuple5<_1,_2,_3,_4,?>> appB)
Sequence both thisApplicative
andappB
, discarding thisApplicative's
result and returningappB
. This is generally useful for sequentially performing side-effects.
-
discardR
public <_5Prime> Tuple5<_1,_2,_3,_4,_5> discardR(Applicative<_5Prime,Tuple5<_1,_2,_3,_4,?>> appB)
Sequence both thisApplicative
andappB
, discardingappB's
result and returning thisApplicative
. This is generally useful for sequentially performing side-effects.
-
flatMap
public <_5Prime> Tuple5<_1,_2,_3,_4,_5Prime> flatMap(Fn1<? super _5,? extends Monad<_5Prime,Tuple5<_1,_2,_3,_4,?>>> f)
Chain dependent computations that may continue or short-circuit based on previous results.
-
trampolineM
public <_5Prime> Tuple5<_1,_2,_3,_4,_5Prime> trampolineM(Fn1<? super _5,? extends MonadRec<RecursiveResult<_5,_5Prime>,Tuple5<_1,_2,_3,_4,?>>> fn)
Given some operation yielding aRecursiveResult
inside thisMonadRec
, internally trampoline the operation until it yields atermination
instruction.Stack-safety depends on implementations guaranteeing that the growth of the call stack is a constant factor independent of the number of invocations of the operation. For various examples of how this can be achieved in stereotypical circumstances, see the referenced types.
- Specified by:
trampolineM
in interfaceMonadRec<_1,_2>
- Type Parameters:
_5Prime
- the ultimate resulting carrier type- Parameters:
fn
- the function to internally trampoline- Returns:
- the trampolined
MonadRec
- See Also:
for a basic implementation
,for a implementation
,for an implementation leveraging an already stack-safe
,for a implementation
-
traverse
public <_5Prime,App extends Applicative<?,App>,TravB extends Traversable<_5Prime,Tuple5<_1,_2,_3,_4,?>>,AppTrav extends Applicative<TravB,App>> AppTrav traverse(Fn1<? super _5,? extends Applicative<_5Prime,App>> fn, Fn1<? super TravB,? extends AppTrav> pure)
Applyfn
to each element of this traversable from left to right, and collapse the results into a single resulting applicative, potentially with the assistance of the applicative's pure function.- Specified by:
traverse
in interfaceTraversable<_1,_2>
- Type Parameters:
_5Prime
- the resulting element typeApp
- the result applicative typeTravB
- this Traversable instance over BAppTrav
- the full inferred resulting type from the traversal- Parameters:
fn
- the function to applypure
- the applicative pure function- Returns:
- the traversed Traversable, wrapped inside an applicative
-
init
public Tuple4<_1,_2,_3,_4> init()
Returns a
of all the elements of thisTuple4
<_1, _2, _3, _4>
except the last.Tuple5
<_1, _2, _3, _4, _5>- Returns:
- The
Tuple4
<_1, _2, _3, _4> representing all but the last element
-
fill
public static <A> Tuple5<A,A,A,A,A> fill(A a)
Given a value of typeA
, produced an instance of this tuple with each slot set to that value.- Type Parameters:
A
- the value type- Parameters:
a
- the value to fill the tuple with- Returns:
- the filled tuple
- See Also:
Tuple2.fill(A)
-
fromIterable
public static <A> Maybe<Tuple5<A,A,A,A,A>> fromIterable(java.lang.Iterable<A> as)
Returnjust
the first five elements from the givenIterable
, ornothing
if there are less than five elements.- Type Parameters:
A
- theIterable
element type- Parameters:
as
- theIterable
- Returns:
Maybe
the first five elements of the givenIterable
-
pureTuple
public static <_1,_2,_3,_4> Pure<Tuple5<_1,_2,_3,_4,?>> pureTuple(_1 _1, _2 _2, _3 _3, _4 _4)
- Type Parameters:
_1
- the head element type_2
- the second element type_3
- the third element type_4
- the fourth element type- Parameters:
_1
- the head element_2
- the second element_3
- the third element_4
- the fourth element- Returns:
- the
Pure
instance
-
-