Interface CoProduct4<A,B,C,D,CP4 extends CoProduct4<A,B,C,D,?>>
- Type Parameters:
A- the first possible typeB- the second possible typeC- the third possible typeD- the fourth possible typeCP4- the recursive type of this coproduct (used for embedding)
- All Known Implementing Classes:
Choice4,Choice4._A,Choice4._B,Choice4._C,Choice4._D
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
A generalization of the coproduct of four types.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptiondefault CoProduct3<A, B, C, ? extends CoProduct3<A, B, C, ?>> Converge this coproduct down to a lower order coproduct by mapping the last possible type into an earlier possible type.default <E> CoProduct5<A, B, C, D, E, ? extends CoProduct5<A, B, C, D, E, ?>> diverge()Diverge this coproduct by introducing another possible type that it could represent.default <R> Rembed(Fn1<? super CP4, ? extends R> aFn, Fn1<? super CP4, ? extends R> bFn, Fn1<? super CP4, ? extends R> cFn, Fn1<? super CP4, ? extends R> dFn) Embed this coproduct inside another value; that is, given morphisms from this coproduct toR, apply the appropriate morphism to this coproduct as a whole.<R> Rmatch(Fn1<? super A, ? extends R> aFn, Fn1<? super B, ? extends R> bFn, Fn1<? super C, ? extends R> cFn, Fn1<? super D, ? extends R> dFn) Type-safe convergence requiring a match against all potential types.project()Project this coproduct onto a product.projectA()Convenience method for projecting this coproduct onto a product and then extracting the first slot value.projectB()Convenience method for projecting this coproduct onto a product and then extracting the second slot value.projectC()Convenience method for projecting this coproduct onto a product and then extracting the third slot value.projectD()Convenience method for projecting this coproduct onto a product and then extracting the fourth slot value.
-
Method Details
-
match
<R> R match(Fn1<? super A, ? extends R> aFn, Fn1<? super B, ? extends R> bFn, Fn1<? super C, ? extends R> cFn, Fn1<? super D, ? extends R> dFn) Type-safe convergence requiring a match against all potential types.- Type Parameters:
R- result type- Parameters:
aFn- morphismA -> RbFn- morphismB -> RcFn- morphismC -> RdFn- morphismD -> R- Returns:
- the result of applying the appropriate morphism from whichever type is represented by this coproduct to R
- See Also:
-
diverge
Diverge this coproduct by introducing another possible type that it could represent.- Type Parameters:
E- the additional possible type of this coproduct- Returns:
- a Coproduct5<A, B, C, D, E>
- See Also:
-
converge
default CoProduct3<A,B, convergeC, ? extends CoProduct3<A, B, C, ?>> (Fn1<? super D, ? extends CoProduct3<A, B, C, ?>> convergenceFn) Converge this coproduct down to a lower order coproduct by mapping the last possible type into an earlier possible type.- Parameters:
convergenceFn- function from last possible type to earlier type- Returns:
- a
CoProduct3<A, B, C> - See Also:
-
project
Project this coproduct onto a product.- Returns:
- a product of the coproduct projection
- See Also:
-
projectA
Convenience method for projecting this coproduct onto a product and then extracting the first slot value.- Returns:
- an optional value representing the projection of the "a" type index
-
projectB
Convenience method for projecting this coproduct onto a product and then extracting the second slot value.- Returns:
- an optional value representing the projection of the "b" type index
-
projectC
Convenience method for projecting this coproduct onto a product and then extracting the third slot value.- Returns:
- an optional value representing the projection of the "c" type index
-
projectD
Convenience method for projecting this coproduct onto a product and then extracting the fourth slot value.- Returns:
- an optional value representing the projection of the "d" type index
-
embed
default <R> R embed(Fn1<? super CP4, ? extends R> aFn, Fn1<? super CP4, ? extends R> bFn, Fn1<? super CP4, ? extends R> cFn, Fn1<? super CP4, ? extends R> dFn) Embed this coproduct inside another value; that is, given morphisms from this coproduct toR, apply the appropriate morphism to this coproduct as a whole. Likematch(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>, com.jnape.palatable.lambda.functions.Fn1<? super D, ? extends R>), but without unwrapping the value.- Type Parameters:
R- result type- Parameters:
aFn- morphismA v B v C v D -> R, applied in theAcasebFn- morphismA v B v C v D -> R, applied in theBcasecFn- morphismA v B v C v D -> R, applied in theCcasedFn- morphismA v B v C v D -> R, applied in theDcase- Returns:
- the result of applying the appropriate morphism to this coproduct
-