Class Choice8<A,B,C,D,E,F,G,H>

java.lang.Object
com.jnape.palatable.lambda.adt.choice.Choice8<A,B,C,D,E,F,G,H>
Type Parameters:
A - the first possible type
B - the second possible type
C - the third possible type
D - the fourth possible type
E - the fifth possible type
F - the sixth possible type
G - the seventh possible type
H - the eighth possible type
All Implemented Interfaces:
CoProduct8<A,B,C,D,E,F,G,H,Choice8<A,B,C,D,E,F,G,H>>, Applicative<H,Choice8<A,B,C,D,E,F,G,?>>, Bifunctor<G,H,Choice8<A,B,C,D,E,F,?,?>>, BoundedBifunctor<G,H,Object,Object,Choice8<A,B,C,D,E,F,?,?>>, Functor<H,Choice8<A,B,C,D,E,F,G,?>>, Monad<H,Choice8<A,B,C,D,E,F,G,?>>, MonadRec<H,Choice8<A,B,C,D,E,F,G,?>>, Traversable<H,Choice8<A,B,C,D,E,F,G,?>>
Direct Known Subclasses:
Choice8._A, Choice8._B, Choice8._C, Choice8._D, Choice8._E, Choice8._F, Choice8._G, Choice8._H

public abstract class Choice8<A,B,C,D,E,F,G,H> extends Object implements CoProduct8<A,B,C,D,E,F,G,H,Choice8<A,B,C,D,E,F,G,H>>, MonadRec<H,Choice8<A,B,C,D,E,F,G,?>>, Bifunctor<G,H,Choice8<A,B,C,D,E,F,?,?>>, Traversable<H,Choice8<A,B,C,D,E,F,G,?>>
Canonical ADT representation of CoProduct8.
See Also:
  • Constructor Details

    • Choice8

      private Choice8()
  • Method Details

    • project

      public Tuple8<Maybe<A>,Maybe<B>,Maybe<C>,Maybe<D>,Maybe<E>,Maybe<F>,Maybe<G>,Maybe<H>> project()
      Specialize this choice's projection to a Tuple8.
      Specified by:
      project in interface CoProduct8<A,B,C,D,E,F,G,H,Choice8<A,B,C,D,E,F,G,H>>
      Returns:
      a Tuple8
      See Also:
    • converge

      public Choice7<A,B,C,D,E,F,G> converge(Fn1<? super H,? extends CoProduct7<A,B,C,D,E,F,G,?>> convergenceFn)
      Converge this coproduct down to a lower order coproduct by mapping the last possible type into an earlier possible type.
      Specified by:
      converge in interface CoProduct8<A,B,C,D,E,F,G,H,Choice8<A,B,C,D,E,F,G,H>>
      Parameters:
      convergenceFn - morphism G -> CoProduct6<A, B, C, D, E, F, G>
      Returns:
      a CoProduct7<A, B, C, D, E, F, G>
    • fmap

      public <I> Choice8<A,B,C,D,E,F,G,I> fmap(Fn1<? super H,? extends I> fn)
      Covariantly transmute this functor's parameter using the given mapping function. Generally this method is specialized to return an instance of the class implementing Functor.
      Specified by:
      fmap in interface Applicative<A,B>
      Specified by:
      fmap in interface Functor<A,B>
      Specified by:
      fmap in interface Monad<A,B>
      Specified by:
      fmap in interface MonadRec<A,B>
      Specified by:
      fmap in interface Traversable<A,B>
      Type Parameters:
      I - the new parameter type
      Parameters:
      fn - the mapping function
      Returns:
      a functor over B (the new parameter type)
    • biMapL

      public <I> Choice8<A,B,C,D,E,F,I,H> biMapL(Fn1<? super G,? extends I> fn)
      Covariantly map over the left parameter.
      Specified by:
      biMapL in interface Bifunctor<A,B,C>
      Specified by:
      biMapL in interface BoundedBifunctor<A,B,C,D,E>
      Type Parameters:
      I - the new left parameter type
      Parameters:
      fn - the mapping function
      Returns:
      a bifunctor over C (the new left parameter) and B (the same right parameter)
    • biMapR

      public <I> Choice8<A,B,C,D,E,F,G,I> biMapR(Fn1<? super H,? extends I> fn)
      Covariantly map over the right parameter. For all bifunctors that are also functors, it should hold that biMapR(f) == fmap(f).
      Specified by:
      biMapR in interface Bifunctor<A,B,C>
      Specified by:
      biMapR in interface BoundedBifunctor<A,B,C,D,E>
      Type Parameters:
      I - the new right parameter type
      Parameters:
      fn - the mapping function
      Returns:
      a bifunctor over A (the same left parameter) and C (the new right parameter)
    • biMap

      public <I, J> Choice8<A,B,C,D,E,F,I,J> biMap(Fn1<? super G,? extends I> lFn, Fn1<? super H,? extends J> rFn)
      Dually map covariantly over both the left and right parameters. This is isomorphic to biMapL(lFn).biMapR(rFn).
      Specified by:
      biMap in interface Bifunctor<A,B,C>
      Specified by:
      biMap in interface BoundedBifunctor<A,B,C,D,E>
      Type Parameters:
      I - the new left parameter type
      J - the new right parameter type
      Parameters:
      lFn - the left parameter mapping function
      rFn - the right parameter mapping function
      Returns:
      a bifunctor over C (the new left parameter type) and D (the new right parameter type)
    • pure

      public <I> Choice8<A,B,C,D,E,F,G,I> pure(I i)
      Lift the value b into this applicative functor.
      Specified by:
      pure in interface Applicative<A,B>
      Specified by:
      pure in interface Monad<A,B>
      Specified by:
      pure in interface MonadRec<A,B>
      Type Parameters:
      I - the type of the returned applicative's parameter
      Parameters:
      i - the value
      Returns:
      an instance of this applicative over b
    • zip

      public <I> Choice8<A,B,C,D,E,F,G,I> zip(Applicative<Fn1<? super H,? extends I>,Choice8<A,B,C,D,E,F,G,?>> appFn)
      Given another instance of this applicative over a mapping function, "zip" the two instances together using whatever application semantics the current applicative supports.
      Specified by:
      zip in interface Applicative<A,B>
      Specified by:
      zip in interface Monad<A,B>
      Specified by:
      zip in interface MonadRec<A,B>
      Type Parameters:
      I - the resulting applicative parameter type
      Parameters:
      appFn - the other applicative instance
      Returns:
      the mapped applicative
    • lazyZip

      public <I> Lazy<Choice8<A,B,C,D,E,F,G,I>> lazyZip(Lazy<? extends Applicative<Fn1<? super H,? extends I>,Choice8<A,B,C,D,E,F,G,?>>> 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. This is useful for applicatives that support lazy evaluation and early termination.
      Specified by:
      lazyZip in interface Applicative<A,B>
      Specified by:
      lazyZip in interface Monad<A,B>
      Specified by:
      lazyZip in interface MonadRec<A,B>
      Type Parameters:
      I - the resulting applicative parameter type
      Parameters:
      lazyAppFn - the lazy other applicative instance
      Returns:
      the mapped applicative
      See Also:
    • discardL

      public <I> Choice8<A,B,C,D,E,F,G,I> discardL(Applicative<I,Choice8<A,B,C,D,E,F,G,?>> appB)
      Sequence both this Applicative and appB, discarding this Applicative's result and returning appB. This is generally useful for sequentially performing side-effects.
      Specified by:
      discardL in interface Applicative<A,B>
      Specified by:
      discardL in interface Monad<A,B>
      Specified by:
      discardL in interface MonadRec<A,B>
      Type Parameters:
      I - the type of the returned Applicative's parameter
      Parameters:
      appB - the other Applicative
      Returns:
      appB
    • discardR

      public <I> Choice8<A,B,C,D,E,F,G,H> discardR(Applicative<I,Choice8<A,B,C,D,E,F,G,?>> appB)
      Sequence both this Applicative and appB, discarding appB's result and returning this Applicative. This is generally useful for sequentially performing side-effects.
      Specified by:
      discardR in interface Applicative<A,B>
      Specified by:
      discardR in interface Monad<A,B>
      Specified by:
      discardR in interface MonadRec<A,B>
      Type Parameters:
      I - the type of appB's parameter
      Parameters:
      appB - the other Applicative
      Returns:
      this Applicative
    • flatMap

      public <I> Choice8<A,B,C,D,E,F,G,I> flatMap(Fn1<? super H,? extends Monad<I,Choice8<A,B,C,D,E,F,G,?>>> fn)
      Chain dependent computations that may continue or short-circuit based on previous results.
      Specified by:
      flatMap in interface Monad<A,B>
      Specified by:
      flatMap in interface MonadRec<A,B>
      Type Parameters:
      I - the resulting monad parameter type
      Parameters:
      fn - the dependent computation over A
      Returns:
      the new monad instance
    • trampolineM

      public <I> Choice8<A,B,C,D,E,F,G,I> trampolineM(Fn1<? super H,? extends MonadRec<RecursiveResult<H,I>,Choice8<A,B,C,D,E,F,G,?>>> fn)
      Given some operation yielding a 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.

      Specified by:
      trampolineM in interface MonadRec<A,B>
      Type Parameters:
      I - the ultimate resulting carrier type
      Parameters:
      fn - the function to internally trampoline
      Returns:
      the trampolined MonadRec
      See Also:
    • traverse

      public <I, App extends Applicative<?, App>, TravB extends Traversable<I, Choice8<A, B, C, D, E, F, G, ?>>, AppTrav extends Applicative<TravB, App>> AppTrav traverse(Fn1<? super H,? extends Applicative<I,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.
      Specified by:
      traverse in interface Traversable<A,B>
      Type Parameters:
      I - the resulting element type
      App - the result applicative type
      TravB - this Traversable instance over B
      AppTrav - the full inferred resulting type from the traversal
      Parameters:
      fn - the function to apply
      pure - the applicative pure function
      Returns:
      the traversed Traversable, wrapped inside an applicative
    • a

      public static <A, B, C, D, E, F, G, H> Choice8<A,B,C,D,E,F,G,H> a(A a)
      Static factory method for wrapping a value of type A in a Choice8.
      Type Parameters:
      A - the first possible type
      B - the second possible type
      C - the third possible type
      D - the fourth possible type
      E - the fifth possible type
      F - the sixth possible type
      G - the seventh possible type
      H - the eighth possible type
      Parameters:
      a - the value
      Returns:
      the wrapped value as a Choice8<A, B, C, D, E, F, G, H>
    • b

      public static <A, B, C, D, E, F, G, H> Choice8<A,B,C,D,E,F,G,H> b(B b)
      Static factory method for wrapping a value of type B in a Choice8.
      Type Parameters:
      A - the first possible type
      B - the second possible type
      C - the third possible type
      D - the fourth possible type
      E - the fifth possible type
      F - the sixth possible type
      G - the seventh possible type
      H - the eighth possible type
      Parameters:
      b - the value
      Returns:
      the wrapped value as a Choice8<A, B, C, D, E, F, G, H>
    • c

      public static <A, B, C, D, E, F, G, H> Choice8<A,B,C,D,E,F,G,H> c(C c)
      Static factory method for wrapping a value of type C in a Choice8.
      Type Parameters:
      A - the first possible type
      B - the second possible type
      C - the third possible type
      D - the fourth possible type
      E - the fifth possible type
      F - the sixth possible type
      G - the seventh possible type
      H - the eighth possible type
      Parameters:
      c - the value
      Returns:
      the wrapped value as a Choice8<A, B, C, D, E, F, G, H>
    • d

      public static <A, B, C, D, E, F, G, H> Choice8<A,B,C,D,E,F,G,H> d(D d)
      Static factory method for wrapping a value of type D in a Choice8.
      Type Parameters:
      A - the first possible type
      B - the second possible type
      C - the third possible type
      D - the fourth possible type
      E - the fifth possible type
      F - the sixth possible type
      G - the seventh possible type
      H - the eighth possible type
      Parameters:
      d - the value
      Returns:
      the wrapped value as a Choice8<A, B, C, D, E, F, G, H>
    • e

      public static <A, B, C, D, E, F, G, H> Choice8<A,B,C,D,E,F,G,H> e(E e)
      Static factory method for wrapping a value of type E in a Choice8.
      Type Parameters:
      A - the first possible type
      B - the second possible type
      C - the third possible type
      D - the fourth possible type
      E - the fifth possible type
      F - the sixth possible type
      G - the seventh possible type
      H - the eighth possible type
      Parameters:
      e - the value
      Returns:
      the wrapped value as a Choice8<A, B, C, D, E, F, G, H>
    • f

      public static <A, B, C, D, E, F, G, H> Choice8<A,B,C,D,E,F,G,H> f(F f)
      Static factory method for wrapping a value of type F in a Choice8.
      Type Parameters:
      A - the first possible type
      B - the second possible type
      C - the third possible type
      D - the fourth possible type
      E - the fifth possible type
      F - the sixth possible type
      G - the seventh possible type
      H - the eighth possible type
      Parameters:
      f - the value
      Returns:
      the wrapped value as a Choice8<A, B, C, D, E, F, G, H>
    • g

      public static <A, B, C, D, E, F, G, H> Choice8<A,B,C,D,E,F,G,H> g(G g)
      Static factory method for wrapping a value of type G in a Choice8.
      Type Parameters:
      A - the first possible type
      B - the second possible type
      C - the third possible type
      D - the fourth possible type
      E - the fifth possible type
      F - the sixth possible type
      G - the seventh possible type
      H - the eighth possible type
      Parameters:
      g - the value
      Returns:
      the wrapped value as a Choice8<A, B, C, D, E, F, G, H>
    • h

      public static <A, B, C, D, E, F, G, H> Choice8<A,B,C,D,E,F,G,H> h(H h)
      Static factory method for wrapping a value of type H in a Choice8.
      Type Parameters:
      A - the first possible type
      B - the second possible type
      C - the third possible type
      D - the fourth possible type
      E - the fifth possible type
      F - the sixth possible type
      G - the seventh possible type
      H - the eighth possible type
      Parameters:
      h - the value
      Returns:
      the wrapped value as a Choice8<A, B, C, D, E, F, G, H>
    • pureChoice

      public static <A, B, C, D, E, F, G> Pure<Choice8<A,B,C,D,E,F,G,?>> pureChoice()
      The canonical Pure instance for Choice8.
      Type Parameters:
      A - the first possible type
      B - the second possible type
      C - the third possible type
      D - the fourth possible type
      E - the fifth possible type
      F - the sixth possible type
      G - the seventh possible type
      Returns:
      the Pure instance