A
- the first possible typeB
- the second possible typeC
- the third possible typeCP3
- the recursive type of this coproduct (used for embedding)@FunctionalInterface public interface CoProduct3<A,B,C,CP3 extends CoProduct3<A,B,C,?>>
CoProduct2
Modifier and Type | Method and Description |
---|---|
default CoProduct2<A,B,? extends CoProduct2<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.
|
default <D> CoProduct4<A,B,C,D,? extends CoProduct4<A,B,C,D,?>> |
diverge()
Diverge this coproduct by introducing another possible type that it could represent.
|
default <R> R |
embed(Fn1<? super CP3,? extends R> aFn,
Fn1<? super CP3,? extends R> bFn,
Fn1<? super CP3,? extends R> cFn)
Embed this coproduct inside another value; that is, given morphisms from this coproduct to
R , apply
the appropriate morphism to this coproduct as a whole. |
<R> R |
match(Fn1<? super A,? extends R> aFn,
Fn1<? super B,? extends R> bFn,
Fn1<? super C,? extends R> cFn)
Type-safe convergence requiring a match against all potential types.
|
default Product3<Maybe<A>,Maybe<B>,Maybe<C>> |
project()
Project this coproduct onto a product.
|
default Maybe<A> |
projectA()
Convenience method for projecting this coproduct onto a product and then extracting the first slot value.
|
default Maybe<B> |
projectB()
Convenience method for projecting this coproduct onto a product and then extracting the second slot value.
|
default Maybe<C> |
projectC()
Convenience method for projecting this coproduct onto a product and then extracting the third slot value.
|
<R> R match(Fn1<? super A,? extends R> aFn, Fn1<? super B,? extends R> bFn, Fn1<? super C,? extends R> cFn)
R
- result typeaFn
- morphism A -> R
bFn
- morphism B -> R
cFn
- morphism C -> R
CoProduct2.match(Fn1, Fn1)
default <D> CoProduct4<A,B,C,D,? extends CoProduct4<A,B,C,D,?>> diverge()
D
- the additional possible type of this coproductCoProduct4
<A, B, C, D>CoProduct2.diverge()
default CoProduct2<A,B,? extends CoProduct2<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
convergenceFn
- function from last possible type to earlier typeCoProduct2
<A, B>default Product3<Maybe<A>,Maybe<B>,Maybe<C>> project()
CoProduct2.project()
default Maybe<A> projectA()
default Maybe<B> projectB()
default Maybe<C> projectC()
default <R> R embed(Fn1<? super CP3,? extends R> aFn, Fn1<? super CP3,? extends R> bFn, Fn1<? super CP3,? extends R> cFn)
R
, apply
the appropriate morphism to this coproduct as a whole. Like match(com.jnape.palatable.lambda.functions.Fn1<? super A, ? extends R>, com.jnape.palatable.lambda.functions.Fn1<? super B, ? extends R>, com.jnape.palatable.lambda.functions.Fn1<? super C, ? extends R>)
, but without unwrapping the
value.R
- result typeaFn
- morphism A v B v C -> R
, applied in the A
casebFn
- morphism A v B v C -> R
, applied in the B
casecFn
- morphism A v B v C -> R
, applied in the C
case