A
- the first possible typeB
- the second possible typepublic abstract class These<A,B> extends Object implements CoProduct3<A,B,Tuple2<A,B>,These<A,B>>, MonadRec<B,These<A,?>>, Bifunctor<A,B,These<?,?>>, Traversable<B,These<A,?>>
CoProduct2
<A, B>
) and its product (Tuple2
<A, B>
), represented as a CoProduct3
<A, B, Tuple2
<A,
B>>
.Modifier and Type | Method and Description |
---|---|
static <A,B> These<A,B> |
a(A a)
Static factory method for wrapping a value of type
A in a These . |
static <A,B> These<A,B> |
b(B b)
Static factory method for wrapping a value of type
B in a These . |
<C,D> These<C,D> |
biMap(Fn1<? super A,? extends C> lFn,
Fn1<? super B,? extends D> rFn)
Dually map covariantly over both the left and right parameters.
|
<Z> These<Z,B> |
biMapL(Fn1<? super A,? extends Z> fn)
Covariantly map over the left parameter.
|
<C> These<A,C> |
biMapR(Fn1<? super B,? extends C> fn)
Covariantly map over the right parameter.
|
static <A,B> These<A,B> |
both(A a,
B b)
|
<C> These<A,C> |
discardL(Applicative<C,These<A,?>> appB)
Sequence both this
Applicative and appB , discarding this Applicative's
result and returning appB . |
<C> These<A,B> |
discardR(Applicative<C,These<A,?>> appB)
Sequence both this
Applicative and appB , discarding appB's result and
returning this Applicative . |
<C> These<A,C> |
flatMap(Fn1<? super B,? extends Monad<C,These<A,?>>> f)
Chain dependent computations that may continue or short-circuit based on previous results.
|
<C> These<A,C> |
fmap(Fn1<? super B,? extends C> fn)
Covariantly transmute this functor's parameter using the given mapping function.
|
<C> Lazy<These<A,C>> |
lazyZip(Lazy<? extends Applicative<Fn1<? super B,? extends C>,These<A,?>>> 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. |
<C> These<A,C> |
pure(C c)
Lift the value
b into this applicative functor. |
static <A> Pure<These<A,?>> |
pureThese()
|
<C> These<A,C> |
trampolineM(Fn1<? super B,? extends MonadRec<RecursiveResult<B,C>,These<A,?>>> fn)
Given some operation yielding a
RecursiveResult inside this MonadRec , internally trampoline the
operation until it yields a termination instruction. |
<C,App extends Applicative<?,App>,TravC extends Traversable<C,These<A,?>>,AppTrav extends Applicative<TravC,App>> |
traverse(Fn1<? super B,? extends Applicative<C,App>> fn,
Fn1<? super TravC,? 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. |
<C> These<A,C> |
zip(Applicative<Fn1<? super B,? extends C>,These<A,?>> appFn)
Given another instance of this applicative over a mapping function, "zip" the two instances together using
whatever application semantics the current applicative supports.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
public final <C,D> These<C,D> biMap(Fn1<? super A,? extends C> lFn, Fn1<? super B,? extends D> rFn)
biMapL(lFn).biMapR(rFn)
.biMap
in interface Bifunctor<A,B,These<?,?>>
biMap
in interface BoundedBifunctor<A,B,Object,Object,These<?,?>>
C
- the new left parameter typeD
- the new right parameter typelFn
- the left parameter mapping functionrFn
- the right parameter mapping functionpublic final <C> These<A,C> flatMap(Fn1<? super B,? extends Monad<C,These<A,?>>> f)
public <C> These<A,C> trampolineM(Fn1<? super B,? extends MonadRec<RecursiveResult<B,C>,These<A,?>>> 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<B,These<A,?>>
C
- 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 final <C> These<A,C> pure(C c)
b
into this applicative functor.pure
in interface Applicative<B,These<A,?>>
pure
in interface Monad<B,These<A,?>>
pure
in interface MonadRec<B,These<A,?>>
C
- the type of the returned applicative's parameterc
- the valuepublic <C,App extends Applicative<?,App>,TravC extends Traversable<C,These<A,?>>,AppTrav extends Applicative<TravC,App>> AppTrav traverse(Fn1<? super B,? extends Applicative<C,App>> fn, Fn1<? super TravC,? 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<B,These<A,?>>
C
- the resulting element typeApp
- the result applicative typeTravC
- this Traversable instance over BAppTrav
- the full inferred resulting type from the traversalfn
- the function to applypure
- the applicative pure functionpublic final <Z> These<Z,B> biMapL(Fn1<? super A,? extends Z> fn)
biMapL
in interface Bifunctor<A,B,These<?,?>>
biMapL
in interface BoundedBifunctor<A,B,Object,Object,These<?,?>>
Z
- the new left parameter typefn
- the mapping functionpublic final <C> These<A,C> biMapR(Fn1<? super B,? extends C> fn)
biMapR(f) == fmap(f)
.biMapR
in interface Bifunctor<A,B,These<?,?>>
biMapR
in interface BoundedBifunctor<A,B,Object,Object,These<?,?>>
C
- the new right parameter typefn
- the mapping functionpublic final <C> These<A,C> fmap(Fn1<? super B,? extends C> fn)
fmap
in interface Applicative<B,These<A,?>>
fmap
in interface Functor<B,These<A,?>>
fmap
in interface Monad<B,These<A,?>>
fmap
in interface MonadRec<B,These<A,?>>
fmap
in interface Traversable<B,These<A,?>>
C
- the new parameter typefn
- the mapping functionpublic final <C> These<A,C> zip(Applicative<Fn1<? super B,? extends C>,These<A,?>> appFn)
zip
in interface Applicative<B,These<A,?>>
zip
in interface Monad<B,These<A,?>>
zip
in interface MonadRec<B,These<A,?>>
C
- the resulting applicative parameter typeappFn
- the other applicative instancepublic <C> Lazy<These<A,C>> lazyZip(Lazy<? extends Applicative<Fn1<? super B,? extends C>,These<A,?>>> 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<B,These<A,?>>
lazyZip
in interface Monad<B,These<A,?>>
lazyZip
in interface MonadRec<B,These<A,?>>
C
- the resulting applicative parameter typelazyAppFn
- the lazy other applicative instanceMaybe
,
Either
public final <C> These<A,C> discardL(Applicative<C,These<A,?>> 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<B,These<A,?>>
discardL
in interface Monad<B,These<A,?>>
discardL
in interface MonadRec<B,These<A,?>>
C
- the type of the returned Applicative's parameterappB
- the other Applicativepublic final <C> These<A,B> discardR(Applicative<C,These<A,?>> appB)
Applicative
and appB
, discarding appB's
result and
returning this Applicative
. This is generally useful for sequentially performing side-effects.public static <A,B> These<A,B> a(A a)
A
in a These
.A
- the first possible typeB
- the second possible typea
- the valueThese
<A,B>
public static <A,B> These<A,B> b(B b)
B
in a These
.A
- the first possible typeB
- the second possible typeb
- the valueThese
<A,B>
public static <A,B> These<A,B> both(A a, B b)
A
- the first possible typeB
- the second possible typea
- the first valueb
- the second valueThese
<A,B>