Class Tuple3<_1,_2,_3>
- java.lang.Object
-
- com.jnape.palatable.lambda.adt.hlist.HList
-
- com.jnape.palatable.lambda.adt.hlist.HList.HCons<_1,Tuple2<_2,_3>>
-
- com.jnape.palatable.lambda.adt.hlist.Tuple3<_1,_2,_3>
-
- Type Parameters:
_1- The first slot element type_2- The second slot element type_3- The third slot element type
- All Implemented Interfaces:
Product2<_1,_2>,Product3<_1,_2,_3>,Applicative<_3,Tuple3<_1,_2,?>>,Bifunctor<_2,_3,Tuple3<_1,?,?>>,BoundedBifunctor<_2,_3,java.lang.Object,java.lang.Object,Tuple3<_1,?,?>>,Functor<_3,Tuple3<_1,_2,?>>,Monad<_3,Tuple3<_1,_2,?>>,MonadRec<_3,Tuple3<_1,_2,?>>,Traversable<_3,Tuple3<_1,_2,?>>,java.util.Map.Entry<_1,_2>
public class Tuple3<_1,_2,_3> extends HList.HCons<_1,Tuple2<_2,_3>> implements Product3<_1,_2,_3>, MonadRec<_3,Tuple3<_1,_2,?>>, Bifunctor<_2,_3,Tuple3<_1,?,?>>, Traversable<_3,Tuple3<_1,_2,?>>
A 3-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.<_2Prime,_3Prime>
Tuple3<_1,_2Prime,_3Prime>biMap(Fn1<? super _2,? extends _2Prime> lFn, Fn1<? super _3,? extends _3Prime> rFn)Dually map covariantly over both the left and right parameters.<_2Prime> Tuple3<_1,_2Prime,_3>biMapL(Fn1<? super _2,? extends _2Prime> fn)Covariantly map over the left parameter.<_3Prime> Tuple3<_1,_2,_3Prime>biMapR(Fn1<? super _3,? extends _3Prime> fn)Covariantly map over the right parameter.<_0> Tuple4<_0,_1,_2,_3>cons(_0 _0)Cons an element onto the front of this HList.<_3Prime> Tuple3<_1,_2,_3Prime>discardL(Applicative<_3Prime,Tuple3<_1,_2,?>> appB)Sequence both thisApplicativeandappB, discarding thisApplicative'sresult and returningappB.<_3Prime> Tuple3<_1,_2,_3>discardR(Applicative<_3Prime,Tuple3<_1,_2,?>> appB)Sequence both thisApplicativeandappB, discardingappB'sresult and returning thisApplicative.static <A> Tuple3<A,A,A>fill(A a)Given a value of typeA, produced an instance of this tuple with each slot set to that value.<_3Prime> Tuple3<_1,_2,_3Prime>flatMap(Fn1<? super _3,? extends Monad<_3Prime,Tuple3<_1,_2,?>>> f)Chain dependent computations that may continue or short-circuit based on previous results.<_3Prime> Tuple3<_1,_2,_3Prime>fmap(Fn1<? super _3,? extends _3Prime> fn)Covariantly transmute this functor's parameter using the given mapping function.static <A> Maybe<Tuple3<A,A,A>>fromIterable(java.lang.Iterable<A> as)Tuple2<_1,_2>init()Tuple3<_2,_1,_3>invert()Rotate the first two slots of this product.<_3Prime> Lazy<Tuple3<_1,_2,_3Prime>>lazyZip(Lazy<? extends Applicative<Fn1<? super _3,? extends _3Prime>,Tuple3<_1,_2,?>>> lazyAppFn)Given alazyinstance of this applicative over a mapping function, "zip" the two instances together using whatever application semantics the current applicative supports.<_3Prime> Tuple3<_1,_2,_3Prime>pure(_3Prime _3Prime)Lift the valuebinto this applicative functor.static <_1,_2>
Pure<Tuple3<_1,_2,?>>pureTuple(_1 _1, _2 _2)Tuple3<_2,_3,_1>rotateL3()Rotate the first three values of this product one slot to the left.Tuple3<_3,_1,_2>rotateR3()Rotate the first three values of this product one slot to the right.<_4> Tuple4<_1,_2,_3,_4>snoc(_4 _4)Snoc an element onto the back of thisTuple3.<_3Prime> Tuple3<_1,_2,_3Prime>trampolineM(Fn1<? super _3,? extends MonadRec<RecursiveResult<_3,_3Prime>,Tuple3<_1,_2,?>>> fn)Given some operation yielding aRecursiveResultinside thisMonadRec, internally trampoline the operation until it yields aterminationinstruction.<_3Prime,App extends Applicative<?,App>,TravB extends Traversable<_3Prime,Tuple3<_1,_2,?>>,AppTrav extends Applicative<TravB,App>>
AppTravtraverse(Fn1<? super _3,? extends Applicative<_3Prime,App>> fn, Fn1<? super TravB,? extends AppTrav> pure)Applyfnto 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.<_3Prime> Tuple3<_1,_2,_3Prime>zip(Applicative<Fn1<? super _3,? extends _3Prime>,Tuple3<_1,_2,?>> 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
-
snoc
public <_4> Tuple4<_1,_2,_3,_4> snoc(_4 _4)
Snoc an element onto the back of thisTuple3.- Type Parameters:
_4- the new last element type- Parameters:
_4- the new last element- Returns:
- the new
Tuple4
-
_1
public _1 _1()
Retrieve the first element.
-
_2
public _2 _2()
Retrieve the second element.
-
_3
public _3 _3()
Retrieve the third element.
-
rotateL3
public Tuple3<_2,_3,_1> rotateL3()
Rotate the first three values of this product one slot to the left.
-
rotateR3
public Tuple3<_3,_1,_2> rotateR3()
Rotate the first three values of this product one slot to the right.
-
fmap
public <_3Prime> Tuple3<_1,_2,_3Prime> fmap(Fn1<? super _3,? extends _3Prime> 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:
fmapin interfaceApplicative<_1,_2>- Specified by:
fmapin interfaceFunctor<_1,_2>- Specified by:
fmapin interfaceMonad<_1,_2>- Specified by:
fmapin interfaceMonadRec<_1,_2>- Specified by:
fmapin interfaceTraversable<_1,_2>- Type Parameters:
_3Prime- the new parameter type- Parameters:
fn- the mapping function- Returns:
- a functor over B (the new parameter type)
-
biMapL
public <_2Prime> Tuple3<_1,_2Prime,_3> biMapL(Fn1<? super _2,? extends _2Prime> fn)
Covariantly map over the left parameter.- Specified by:
biMapLin interfaceBifunctor<_1,_2,_3>- Specified by:
biMapLin interfaceBoundedBifunctor<_2,_3,java.lang.Object,java.lang.Object,Tuple3<_1,?,?>>- Type Parameters:
_2Prime- 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 <_3Prime> Tuple3<_1,_2,_3Prime> biMapR(Fn1<? super _3,? extends _3Prime> fn)
Covariantly map over the right parameter. For all bifunctors that are also functors, it should hold thatbiMapR(f) == fmap(f).- Specified by:
biMapRin interfaceBifunctor<_1,_2,_3>- Specified by:
biMapRin interfaceBoundedBifunctor<_2,_3,java.lang.Object,java.lang.Object,Tuple3<_1,?,?>>- Type Parameters:
_3Prime- 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 <_2Prime,_3Prime> Tuple3<_1,_2Prime,_3Prime> biMap(Fn1<? super _2,? extends _2Prime> lFn, Fn1<? super _3,? extends _3Prime> rFn)
Dually map covariantly over both the left and right parameters. This is isomorphic tobiMapL(lFn).biMapR(rFn).- Specified by:
biMapin interfaceBifunctor<_1,_2,_3>- Specified by:
biMapin interfaceBoundedBifunctor<_2,_3,java.lang.Object,java.lang.Object,Tuple3<_1,?,?>>- Type Parameters:
_2Prime- the new left parameter type_3Prime- 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 <_3Prime> Tuple3<_1,_2,_3Prime> pure(_3Prime _3Prime)
Lift the valuebinto this applicative functor.- Specified by:
purein interfaceApplicative<_1,_2>- Specified by:
purein interfaceMonad<_1,_2>- Specified by:
purein interfaceMonadRec<_1,_2>- Type Parameters:
_3Prime- the type of the returned applicative's parameter- Parameters:
_3Prime- the value- Returns:
- an instance of this applicative over b
-
zip
public <_3Prime> Tuple3<_1,_2,_3Prime> zip(Applicative<Fn1<? super _3,? extends _3Prime>,Tuple3<_1,_2,?>> 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 <_3Prime> Lazy<Tuple3<_1,_2,_3Prime>> lazyZip(Lazy<? extends Applicative<Fn1<? super _3,? extends _3Prime>,Tuple3<_1,_2,?>>> lazyAppFn)
Given alazyinstance 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:
lazyZipin interfaceApplicative<_1,_2>- Specified by:
lazyZipin interfaceMonad<_1,_2>- Specified by:
lazyZipin interfaceMonadRec<_1,_2>- Type Parameters:
_3Prime- the resulting applicative parameter type- Parameters:
lazyAppFn- the lazy other applicative instance- Returns:
- the mapped applicative
- See Also:
Maybe,Either
-
discardL
public <_3Prime> Tuple3<_1,_2,_3Prime> discardL(Applicative<_3Prime,Tuple3<_1,_2,?>> appB)
Sequence both thisApplicativeandappB, discarding thisApplicative'sresult and returningappB. This is generally useful for sequentially performing side-effects.
-
discardR
public <_3Prime> Tuple3<_1,_2,_3> discardR(Applicative<_3Prime,Tuple3<_1,_2,?>> appB)
Sequence both thisApplicativeandappB, discardingappB'sresult and returning thisApplicative. This is generally useful for sequentially performing side-effects.
-
flatMap
public <_3Prime> Tuple3<_1,_2,_3Prime> flatMap(Fn1<? super _3,? extends Monad<_3Prime,Tuple3<_1,_2,?>>> f)
Chain dependent computations that may continue or short-circuit based on previous results.
-
trampolineM
public <_3Prime> Tuple3<_1,_2,_3Prime> trampolineM(Fn1<? super _3,? extends MonadRec<RecursiveResult<_3,_3Prime>,Tuple3<_1,_2,?>>> fn)
Given some operation yielding aRecursiveResultinside thisMonadRec, internally trampoline the operation until it yields aterminationinstruction.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:
trampolineMin interfaceMonadRec<_1,_2>- Type Parameters:
_3Prime- 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 <_3Prime,App extends Applicative<?,App>,TravB extends Traversable<_3Prime,Tuple3<_1,_2,?>>,AppTrav extends Applicative<TravB,App>> AppTrav traverse(Fn1<? super _3,? extends Applicative<_3Prime,App>> fn, Fn1<? super TravB,? extends AppTrav> pure)
Applyfnto 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:
traversein interfaceTraversable<_1,_2>- Type Parameters:
_3Prime- 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
-
fill
public static <A> Tuple3<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<Tuple3<A,A,A>> fromIterable(java.lang.Iterable<A> as)
Returnjustthe first three elements from the givenIterable, ornothingif there are less than three elements.- Type Parameters:
A- theIterableelement type- Parameters:
as- theIterable- Returns:
Maybethe first three elements of the givenIterable
-
-