A
- the first possible typeB
- the second possible typeC
- the third possible typepublic abstract class Choice3<A,B,C> extends Object implements CoProduct3<A,B,C,Choice3<A,B,C>>, MonadRec<C,Choice3<A,B,?>>, Bifunctor<B,C,Choice3<A,?,?>>, Traversable<C,Choice3<A,B,?>>
CoProduct3
.Modifier and Type | Method and Description |
---|---|
static <A,B,C> Choice3<A,B,C> |
a(A a)
Static factory method for wrapping a value of type
A in a Choice3 . |
static <A,B,C> Choice3<A,B,C> |
b(B b)
Static factory method for wrapping a value of type
A in a Choice3 . |
<D,E> Choice3<A,D,E> |
biMap(Fn1<? super B,? extends D> lFn,
Fn1<? super C,? extends E> rFn)
Dually map covariantly over both the left and right parameters.
|
<D> Choice3<A,D,C> |
biMapL(Fn1<? super B,? extends D> fn)
Covariantly map over the left parameter.
|
<D> Choice3<A,B,D> |
biMapR(Fn1<? super C,? extends D> fn)
Covariantly map over the right parameter.
|
static <A,B,C> Choice3<A,B,C> |
c(C c)
Static factory method for wrapping a value of type
A in a Choice3 . |
Choice2<A,B> |
converge(Fn1<? super C,? extends CoProduct2<A,B,?>> convergenceFn)
Converge this coproduct down to a lower order coproduct by mapping the last possible type into an earlier
possible type.
|
<D> Choice3<A,B,D> |
discardL(Applicative<D,Choice3<A,B,?>> appB)
Sequence both this
Applicative and appB , discarding this Applicative's
result and returning appB . |
<D> Choice3<A,B,C> |
discardR(Applicative<D,Choice3<A,B,?>> appB)
Sequence both this
Applicative and appB , discarding appB's result and
returning this Applicative . |
<D> Choice4<A,B,C,D> |
diverge()
Diverge this coproduct by introducing another possible type that it could represent.
|
<D> Choice3<A,B,D> |
flatMap(Fn1<? super C,? extends Monad<D,Choice3<A,B,?>>> f)
Chain dependent computations that may continue or short-circuit based on previous results.
|
<D> Choice3<A,B,D> |
fmap(Fn1<? super C,? extends D> fn)
Covariantly transmute this functor's parameter using the given mapping function.
|
<D> Lazy<Choice3<A,B,D>> |
lazyZip(Lazy<? extends Applicative<Fn1<? super C,? extends D>,Choice3<A,B,?>>> 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. |
Tuple3<Maybe<A>,Maybe<B>,Maybe<C>> |
project()
Specialize this choice's projection to a
Tuple3 . |
<D> Choice3<A,B,D> |
pure(D d)
Lift the value
b into this applicative functor. |
static <A,B> Pure<Choice3<A,B,?>> |
pureChoice()
|
<D> Choice3<A,B,D> |
trampolineM(Fn1<? super C,? extends MonadRec<RecursiveResult<C,D>,Choice3<A,B,?>>> fn)
Given some operation yielding a
RecursiveResult inside this MonadRec , internally trampoline the
operation until it yields a termination instruction. |
<D,App extends Applicative<?,App>,TravB extends Traversable<D,Choice3<A,B,?>>,AppTrav extends Applicative<TravB,App>> |
traverse(Fn1<? super C,? extends Applicative<D,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. |
<D> Choice3<A,B,D> |
zip(Applicative<Fn1<? super C,? extends D>,Choice3<A,B,?>> 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 Tuple3<Maybe<A>,Maybe<B>,Maybe<C>> project()
Tuple3
.public final <D> Choice4<A,B,C,D> diverge()
diverge
in interface CoProduct3<A,B,C,Choice3<A,B,C>>
D
- the additional possible type of this coproductCoProduct4
<A, B, C, D>CoProduct2.diverge()
public final Choice2<A,B> converge(Fn1<? super C,? extends CoProduct2<A,B,?>> convergenceFn)
CoProduct2.diverge()
, which introduces the type
C
and raises the order from 2 to 3.
The following laws hold for any two coproducts of single order difference:
coProductN.diverge().converge(CoProductN::a) == coProductN
converge
in interface CoProduct3<A,B,C,Choice3<A,B,C>>
convergenceFn
- function from last possible type to earlier typeCoProduct2
<A, B>public final <D> Choice3<A,B,D> fmap(Fn1<? super C,? extends D> fn)
fmap
in interface Applicative<C,Choice3<A,B,?>>
fmap
in interface Functor<C,Choice3<A,B,?>>
fmap
in interface Monad<C,Choice3<A,B,?>>
fmap
in interface MonadRec<C,Choice3<A,B,?>>
fmap
in interface Traversable<C,Choice3<A,B,?>>
D
- the new parameter typefn
- the mapping functionpublic final <D> Choice3<A,D,C> biMapL(Fn1<? super B,? extends D> fn)
biMapL
in interface Bifunctor<B,C,Choice3<A,?,?>>
biMapL
in interface BoundedBifunctor<B,C,Object,Object,Choice3<A,?,?>>
D
- the new left parameter typefn
- the mapping functionpublic final <D> Choice3<A,B,D> biMapR(Fn1<? super C,? extends D> fn)
biMapR(f) == fmap(f)
.biMapR
in interface Bifunctor<B,C,Choice3<A,?,?>>
biMapR
in interface BoundedBifunctor<B,C,Object,Object,Choice3<A,?,?>>
D
- the new right parameter typefn
- the mapping functionpublic final <D,E> Choice3<A,D,E> biMap(Fn1<? super B,? extends D> lFn, Fn1<? super C,? extends E> rFn)
biMapL(lFn).biMapR(rFn)
.biMap
in interface Bifunctor<B,C,Choice3<A,?,?>>
biMap
in interface BoundedBifunctor<B,C,Object,Object,Choice3<A,?,?>>
D
- the new left parameter typeE
- the new right parameter typelFn
- the left parameter mapping functionrFn
- the right parameter mapping functionpublic <D> Choice3<A,B,D> pure(D d)
b
into this applicative functor.pure
in interface Applicative<C,Choice3<A,B,?>>
pure
in interface Monad<C,Choice3<A,B,?>>
pure
in interface MonadRec<C,Choice3<A,B,?>>
D
- the type of the returned applicative's parameterd
- the valuepublic <D> Choice3<A,B,D> zip(Applicative<Fn1<? super C,? extends D>,Choice3<A,B,?>> appFn)
zip
in interface Applicative<C,Choice3<A,B,?>>
zip
in interface Monad<C,Choice3<A,B,?>>
zip
in interface MonadRec<C,Choice3<A,B,?>>
D
- the resulting applicative parameter typeappFn
- the other applicative instancepublic <D> Lazy<Choice3<A,B,D>> lazyZip(Lazy<? extends Applicative<Fn1<? super C,? extends D>,Choice3<A,B,?>>> 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<C,Choice3<A,B,?>>
lazyZip
in interface Monad<C,Choice3<A,B,?>>
lazyZip
in interface MonadRec<C,Choice3<A,B,?>>
D
- the resulting applicative parameter typelazyAppFn
- the lazy other applicative instanceMaybe
,
Either
public <D> Choice3<A,B,D> discardL(Applicative<D,Choice3<A,B,?>> 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<C,Choice3<A,B,?>>
discardL
in interface Monad<C,Choice3<A,B,?>>
discardL
in interface MonadRec<C,Choice3<A,B,?>>
D
- the type of the returned Applicative's parameterappB
- the other Applicativepublic <D> Choice3<A,B,C> discardR(Applicative<D,Choice3<A,B,?>> 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<C,Choice3<A,B,?>>
discardR
in interface Monad<C,Choice3<A,B,?>>
discardR
in interface MonadRec<C,Choice3<A,B,?>>
D
- the type of appB's parameterappB
- the other Applicativepublic <D> Choice3<A,B,D> flatMap(Fn1<? super C,? extends Monad<D,Choice3<A,B,?>>> f)
public <D> Choice3<A,B,D> trampolineM(Fn1<? super C,? extends MonadRec<RecursiveResult<C,D>,Choice3<A,B,?>>> 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<C,Choice3<A,B,?>>
D
- 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 <D,App extends Applicative<?,App>,TravB extends Traversable<D,Choice3<A,B,?>>,AppTrav extends Applicative<TravB,App>> AppTrav traverse(Fn1<? super C,? extends Applicative<D,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<C,Choice3<A,B,?>>
D
- 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 <A,B,C> Choice3<A,B,C> a(A a)
A
in a Choice3
.A
- the first possible typeB
- the second possible typeC
- the third possible typea
- the valueChoice3
<A, B, C>public static <A,B,C> Choice3<A,B,C> b(B b)
A
in a Choice3
.A
- the first possible typeB
- the second possible typeC
- the third possible typeb
- the valueChoice3
<A, B, C>public static <A,B,C> Choice3<A,B,C> c(C c)
A
in a Choice3
.A
- the first possible typeB
- the second possible typeC
- the third possible typec
- the valueChoice3
<A, B, C>