_1
- The first slot element type_2
- The second slot element typepublic class Tuple2<_1,_2> extends HList.HCons<_1,SingletonHList<_2>> implements Product2<_1,_2>, MonadRec<_2,Tuple2<_1,?>>, MonadWriter<_1,_2,Tuple2<_1,?>>, Bifunctor<_1,_2,Tuple2<?,?>>, Traversable<_2,Tuple2<_1,?>>
HList.HCons<Head,Tail extends HList>, HList.HNil
Modifier and Type | Method and Description |
---|---|
_1 |
_1()
Retrieve the first element.
|
_2 |
_2()
Retrieve the second element.
|
<_1Prime,_2Prime> |
biMap(Fn1<? super _1,? extends _1Prime> lFn,
Fn1<? super _2,? extends _2Prime> rFn)
Dually map covariantly over both the left and right parameters.
|
<_1Prime> Tuple2<_1Prime,_2> |
biMapL(Fn1<? super _1,? extends _1Prime> fn)
Covariantly map over the left parameter.
|
<_2Prime> Tuple2<_1,_2Prime> |
biMapR(Fn1<? super _2,? extends _2Prime> fn)
Covariantly map over the right parameter.
|
Tuple2<_1,_2> |
censor(Fn1<? super _1,? extends _1> fn)
Update the accumulated state.
|
<_0> Tuple3<_0,_1,_2> |
cons(_0 _0)
Cons an element onto the front of this HList.
|
<_2Prime> Tuple2<_1,_2Prime> |
discardL(Applicative<_2Prime,Tuple2<_1,?>> appB)
Sequence both this
Applicative and appB , discarding this Applicative's
result and returning appB . |
<_2Prime> Tuple2<_1,_2> |
discardR(Applicative<_2Prime,Tuple2<_1,?>> appB)
Sequence both this
Applicative and appB , discarding appB's result and
returning this Applicative . |
static <A> Tuple2<A,A> |
fill(A a)
Given a value of type
A , produce an instance of this tuple with each slot set to that value. |
<_2Prime> Tuple2<_1,_2Prime> |
flatMap(Fn1<? super _2,? extends Monad<_2Prime,Tuple2<_1,?>>> f)
Chain dependent computations that may continue or short-circuit based on previous results.
|
<_2Prime> Tuple2<_1,_2Prime> |
fmap(Fn1<? super _2,? extends _2Prime> fn)
Covariantly transmute this functor's parameter using the given mapping function.
|
static <K,V> Tuple2<K,V> |
fromEntry(Map.Entry<K,V> entry)
Static factory method for creating
Tuple2 s from Map.Entry s. |
static <A> Maybe<Tuple2<A,A>> |
fromIterable(Iterable<A> as)
|
_1 |
getKey() |
_2 |
getValue() |
Tuple2<_2,_1> |
invert()
Rotate the first two slots of this product.
|
<_2Prime> Lazy<Tuple2<_1,_2Prime>> |
lazyZip(Lazy<? extends Applicative<Fn1<? super _2,? extends _2Prime>,Tuple2<_1,?>>> lazyAppFn)
Given a
lazy instance of this applicative over a mapping function, "zip" the two instances together
using whatever application semantics the current applicative supports. |
<_3> Tuple2<_1,Tuple2<_2,_3>> |
listens(Fn1<? super _1,? extends _3> fn)
Map the accumulation into a value and pair it with the current output.
|
<_2Prime> Tuple2<_1,_2Prime> |
pure(_2Prime _2Prime)
Lift the value
b into this applicative functor. |
static <_1> Pure<Tuple2<_1,?>> |
pureTuple(_1 _1)
|
_2 |
setValue(_2 value) |
<_2Prime> Tuple2<_1,_2Prime> |
trampolineM(Fn1<? super _2,? extends MonadRec<RecursiveResult<_2,_2Prime>,Tuple2<_1,?>>> fn)
Given some operation yielding a
RecursiveResult inside this MonadRec , internally trampoline the
operation until it yields a termination instruction. |
<_2Prime,App extends Applicative<?,App>,TravB extends Traversable<_2Prime,Tuple2<_1,?>>,AppTrav extends Applicative<TravB,App>> |
traverse(Fn1<? super _2,? extends Applicative<_2Prime,App>> fn,
Fn1<? super TravB,? extends AppTrav> pure)
Apply
fn 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. |
<_2Prime> Tuple2<_1,_2Prime> |
zip(Applicative<Fn1<? super _2,? extends _2Prime>,Tuple2<_1,?>> appFn)
Given another instance of this applicative over a mapping function, "zip" the two instances together using
whatever application semantics the current applicative supports.
|
equals, hashCode, head, tail
cons, nil, singletonHList, toString, tuple, tuple, tuple, tuple, tuple, tuple, tuple
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
comparingByKey, comparingByKey, comparingByValue, comparingByValue, equals, hashCode
public <_3> Tuple2<_1,Tuple2<_2,_3>> listens(Fn1<? super _1,? extends _3> fn)
listens
in interface MonadWriter<_1,_2,Tuple2<_1,?>>
_3
- the mapped outputfn
- the mapping functionMonadWriter
public Tuple2<_1,_2> censor(Fn1<? super _1,? extends _1> fn)
censor
in interface MonadWriter<_1,_2,Tuple2<_1,?>>
fn
- the update functionMonadWriter
public <_0> Tuple3<_0,_1,_2> cons(_0 _0)
cons
in class HList.HCons<_1,SingletonHList<_2>>
_0
- the new head type_0
- the new head elementpublic _1 _1()
public _2 _2()
public _1 getKey()
public _2 getValue()
public <_2Prime> Tuple2<_1,_2Prime> fmap(Fn1<? super _2,? extends _2Prime> fn)
fmap
in interface Applicative<_2,Tuple2<_1,?>>
fmap
in interface Functor<_2,Tuple2<_1,?>>
fmap
in interface Monad<_2,Tuple2<_1,?>>
fmap
in interface MonadRec<_2,Tuple2<_1,?>>
fmap
in interface MonadWriter<_1,_2,Tuple2<_1,?>>
fmap
in interface Traversable<_2,Tuple2<_1,?>>
_2Prime
- the new parameter typefn
- the mapping functionpublic <_1Prime> Tuple2<_1Prime,_2> biMapL(Fn1<? super _1,? extends _1Prime> fn)
biMapL
in interface Bifunctor<_1,_2,Tuple2<?,?>>
biMapL
in interface BoundedBifunctor<_1,_2,Object,Object,Tuple2<?,?>>
_1Prime
- the new left parameter typefn
- the mapping functionpublic <_2Prime> Tuple2<_1,_2Prime> biMapR(Fn1<? super _2,? extends _2Prime> fn)
biMapR(f) == fmap(f)
.biMapR
in interface Bifunctor<_1,_2,Tuple2<?,?>>
biMapR
in interface BoundedBifunctor<_1,_2,Object,Object,Tuple2<?,?>>
_2Prime
- the new right parameter typefn
- the mapping functionpublic <_1Prime,_2Prime> Tuple2<_1Prime,_2Prime> biMap(Fn1<? super _1,? extends _1Prime> lFn, Fn1<? super _2,? extends _2Prime> rFn)
biMapL(lFn).biMapR(rFn)
.biMap
in interface Bifunctor<_1,_2,Tuple2<?,?>>
biMap
in interface BoundedBifunctor<_1,_2,Object,Object,Tuple2<?,?>>
_1Prime
- the new left parameter type_2Prime
- the new right parameter typelFn
- the left parameter mapping functionrFn
- the right parameter mapping functionpublic <_2Prime> Tuple2<_1,_2Prime> pure(_2Prime _2Prime)
b
into this applicative functor.pure
in interface Applicative<_2,Tuple2<_1,?>>
pure
in interface Monad<_2,Tuple2<_1,?>>
pure
in interface MonadRec<_2,Tuple2<_1,?>>
pure
in interface MonadWriter<_1,_2,Tuple2<_1,?>>
_2Prime
- the type of the returned applicative's parameter_2Prime
- the valuepublic <_2Prime> Tuple2<_1,_2Prime> zip(Applicative<Fn1<? super _2,? extends _2Prime>,Tuple2<_1,?>> appFn)
zip
in interface Applicative<_2,Tuple2<_1,?>>
zip
in interface Monad<_2,Tuple2<_1,?>>
zip
in interface MonadRec<_2,Tuple2<_1,?>>
zip
in interface MonadWriter<_1,_2,Tuple2<_1,?>>
_2Prime
- the resulting applicative parameter typeappFn
- the other applicative instancepublic <_2Prime> Lazy<Tuple2<_1,_2Prime>> lazyZip(Lazy<? extends Applicative<Fn1<? super _2,? extends _2Prime>,Tuple2<_1,?>>> lazyAppFn)
lazy
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.lazyZip
in interface Applicative<_2,Tuple2<_1,?>>
lazyZip
in interface Monad<_2,Tuple2<_1,?>>
lazyZip
in interface MonadRec<_2,Tuple2<_1,?>>
lazyZip
in interface MonadWriter<_1,_2,Tuple2<_1,?>>
_2Prime
- the resulting applicative parameter typelazyAppFn
- the lazy other applicative instanceMaybe
,
Either
public <_2Prime> Tuple2<_1,_2Prime> discardL(Applicative<_2Prime,Tuple2<_1,?>> appB)
Applicative
and appB
, discarding this Applicative's
result and returning appB
. This is generally useful for sequentially performing side-effects.discardL
in interface Applicative<_2,Tuple2<_1,?>>
discardL
in interface Monad<_2,Tuple2<_1,?>>
discardL
in interface MonadRec<_2,Tuple2<_1,?>>
discardL
in interface MonadWriter<_1,_2,Tuple2<_1,?>>
_2Prime
- the type of the returned Applicative's parameterappB
- the other Applicativepublic <_2Prime> Tuple2<_1,_2> discardR(Applicative<_2Prime,Tuple2<_1,?>> appB)
Applicative
and appB
, discarding appB's
result and
returning this Applicative
. This is generally useful for sequentially performing side-effects.discardR
in interface Applicative<_2,Tuple2<_1,?>>
discardR
in interface Monad<_2,Tuple2<_1,?>>
discardR
in interface MonadRec<_2,Tuple2<_1,?>>
discardR
in interface MonadWriter<_1,_2,Tuple2<_1,?>>
_2Prime
- the type of appB's parameterappB
- the other Applicativepublic <_2Prime> Tuple2<_1,_2Prime> flatMap(Fn1<? super _2,? extends Monad<_2Prime,Tuple2<_1,?>>> f)
flatMap
in interface Monad<_2,Tuple2<_1,?>>
flatMap
in interface MonadRec<_2,Tuple2<_1,?>>
flatMap
in interface MonadWriter<_1,_2,Tuple2<_1,?>>
_2Prime
- the resulting monad parameter typef
- the dependent computation over Apublic <_2Prime> Tuple2<_1,_2Prime> trampolineM(Fn1<? super _2,? extends MonadRec<RecursiveResult<_2,_2Prime>,Tuple2<_1,?>>> fn)
RecursiveResult
inside this MonadRec
, internally trampoline the
operation until it yields a termination
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.
trampolineM
in interface MonadRec<_2,Tuple2<_1,?>>
_2Prime
- the ultimate resulting carrier typefn
- the function to internally trampolineMonadRec
for a basic implementation
,
for a {@link CoProduct2 coproduct} implementation
,
for an implementation leveraging an already stack-safe {@link Monad#flatMap(Fn1)}
,
for a {@link MonadT monad transformer} implementation
public <_2Prime,App extends Applicative<?,App>,TravB extends Traversable<_2Prime,Tuple2<_1,?>>,AppTrav extends Applicative<TravB,App>> AppTrav traverse(Fn1<? super _2,? extends Applicative<_2Prime,App>> fn, Fn1<? super TravB,? extends AppTrav> pure)
fn
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.traverse
in interface Traversable<_2,Tuple2<_1,?>>
_2Prime
- the resulting element typeApp
- the result applicative typeTravB
- this Traversable instance over BAppTrav
- the full inferred resulting type from the traversalfn
- the function to applypure
- the applicative pure functionpublic static <K,V> Tuple2<K,V> fromEntry(Map.Entry<K,V> entry)
Tuple2
s from Map.Entry
s.K
- the key parameter type, and first (head) element typeV
- the value parameter type, and second element typeentry
- the map entrypublic static <A> Tuple2<A,A> fill(A a)
A
, produce an instance of this tuple with each slot set to that value.A
- the value typea
- the value to fill the tuple with