Class Choice7<A,B,C,D,E,F,G>

java.lang.Object
com.jnape.palatable.lambda.adt.choice.Choice7<A,B,C,D,E,F,G>
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
All Implemented Interfaces:
CoProduct7<A,B,C,D,E,F,G,Choice7<A,B,C,D,E,F,G>>, Applicative<G,Choice7<A,B,C,D,E,F,?>>, Bifunctor<F,G,Choice7<A,B,C,D,E,?,?>>, BoundedBifunctor<F,G,Object,Object,Choice7<A,B,C,D,E,?,?>>, Functor<G,Choice7<A,B,C,D,E,F,?>>, Monad<G,Choice7<A,B,C,D,E,F,?>>, MonadRec<G,Choice7<A,B,C,D,E,F,?>>, Traversable<G,Choice7<A,B,C,D,E,F,?>>
Direct Known Subclasses:
Choice7._A, Choice7._B, Choice7._C, Choice7._D, Choice7._E, Choice7._F, Choice7._G

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

    • Choice7

      private Choice7()
  • Method Details

    • project

      public Tuple7<Maybe<A>,Maybe<B>,Maybe<C>,Maybe<D>,Maybe<E>,Maybe<F>,Maybe<G>> project()
      Specialize this choice's projection to a Tuple7.
      Specified by:
      project in interface CoProduct7<A,B,C,D,E,F,G,Choice7<A,B,C,D,E,F,G>>
      Returns:
      a Tuple7
      See Also:
    • diverge

      public <H> Choice8<A,B,C,D,E,F,G,H> diverge()
      Diverge this coproduct by introducing another possible type that it could represent.
      Specified by:
      diverge in interface CoProduct7<A,B,C,D,E,F,G,Choice7<A,B,C,D,E,F,G>>
      Type Parameters:
      H - the additional possible type of this coproduct
      Returns:
      a Coproduct8<A, B, C, D, E, F, G, H>
      See Also:
    • converge

      public Choice6<A,B,C,D,E,F> converge(Fn1<? super G,? extends CoProduct6<A,B,C,D,E,F,?>> 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 CoProduct7<A,B,C,D,E,F,G,Choice7<A,B,C,D,E,F,G>>
      Parameters:
      convergenceFn - morphism G -> CoProduct6<A, B, C, D, E, F>
      Returns:
      a CoProduct6<A, B, C, D, E, F>
    • fmap

      public <H> Choice7<A,B,C,D,E,F,H> fmap(Fn1<? super G,? extends H> 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:
      H - the new parameter type
      Parameters:
      fn - the mapping function
      Returns:
      a functor over B (the new parameter type)
    • biMapL

      public <H> Choice7<A,B,C,D,E,H,G> biMapL(Fn1<? super F,? extends H> 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:
      H - 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 <H> Choice7<A,B,C,D,E,F,H> biMapR(Fn1<? super G,? extends H> 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:
      H - 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 <H, I> Choice7<A,B,C,D,E,H,I> biMap(Fn1<? super F,? extends H> lFn, Fn1<? super G,? extends I> 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:
      H - the new left parameter type
      I - 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 <H> Choice7<A,B,C,D,E,F,H> pure(H h)
      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:
      H - the type of the returned applicative's parameter
      Parameters:
      h - the value
      Returns:
      an instance of this applicative over b
    • zip

      public <H> Choice7<A,B,C,D,E,F,H> zip(Applicative<Fn1<? super G,? extends H>,Choice7<A,B,C,D,E,F,?>> 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:
      H - the resulting applicative parameter type
      Parameters:
      appFn - the other applicative instance
      Returns:
      the mapped applicative
    • lazyZip

      public <H> Lazy<Choice7<A,B,C,D,E,F,H>> lazyZip(Lazy<? extends Applicative<Fn1<? super G,? extends H>,Choice7<A,B,C,D,E,F,?>>> 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:
      H - the resulting applicative parameter type
      Parameters:
      lazyAppFn - the lazy other applicative instance
      Returns:
      the mapped applicative
      See Also:
    • discardL

      public <H> Choice7<A,B,C,D,E,F,H> discardL(Applicative<H,Choice7<A,B,C,D,E,F,?>> 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:
      H - the type of the returned Applicative's parameter
      Parameters:
      appB - the other Applicative
      Returns:
      appB
    • discardR

      public <H> Choice7<A,B,C,D,E,F,G> discardR(Applicative<H,Choice7<A,B,C,D,E,F,?>> 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:
      H - the type of appB's parameter
      Parameters:
      appB - the other Applicative
      Returns:
      this Applicative
    • flatMap

      public <H> Choice7<A,B,C,D,E,F,H> flatMap(Fn1<? super G,? extends Monad<H,Choice7<A,B,C,D,E,F,?>>> 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:
      H - the resulting monad parameter type
      Parameters:
      fn - the dependent computation over A
      Returns:
      the new monad instance
    • trampolineM

      public <H> Choice7<A,B,C,D,E,F,H> trampolineM(Fn1<? super G,? extends MonadRec<RecursiveResult<G,H>,Choice7<A,B,C,D,E,F,?>>> 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:
      H - the ultimate resulting carrier type
      Parameters:
      fn - the function to internally trampoline
      Returns:
      the trampolined MonadRec
      See Also:
    • traverse

      public <H, App extends Applicative<?, App>, TravB extends Traversable<H, Choice7<A, B, C, D, E, F, ?>>, AppTrav extends Applicative<TravB, App>> AppTrav traverse(Fn1<? super G,? extends Applicative<H,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:
      H - 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> Choice7<A,B,C,D,E,F,G> a(A a)
      Static factory method for wrapping a value of type A in a Choice7.
      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
      Parameters:
      a - the value
      Returns:
      the wrapped value as a Choice7<A, B, C, D, E, F, G>
    • b

      public static <A, B, C, D, E, F, G> Choice7<A,B,C,D,E,F,G> b(B b)
      Static factory method for wrapping a value of type B in a Choice7.
      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
      Parameters:
      b - the value
      Returns:
      the wrapped value as a Choice7<A, B, C, D, E, F, G>
    • c

      public static <A, B, C, D, E, F, G> Choice7<A,B,C,D,E,F,G> c(C c)
      Static factory method for wrapping a value of type C in a Choice7.
      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
      Parameters:
      c - the value
      Returns:
      the wrapped value as a Choice7<A, B, C, D, E, F, G>
    • d

      public static <A, B, C, D, E, F, G> Choice7<A,B,C,D,E,F,G> d(D d)
      Static factory method for wrapping a value of type D in a Choice7.
      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
      Parameters:
      d - the value
      Returns:
      the wrapped value as a Choice7<A, B, C, D, E, F, G>
    • e

      public static <A, B, C, D, E, F, G> Choice7<A,B,C,D,E,F,G> e(E e)
      Static factory method for wrapping a value of type E in a Choice7.
      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
      Parameters:
      e - the value
      Returns:
      the wrapped value as a Choice7<A, B, C, D, E, F, G>
    • f

      public static <A, B, C, D, E, F, G> Choice7<A,B,C,D,E,F,G> f(F f)
      Static factory method for wrapping a value of type F in a Choice7.
      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
      Parameters:
      f - the value
      Returns:
      the wrapped value as a Choice7<A, B, C, D, E, F, G>
    • g

      public static <A, B, C, D, E, F, G> Choice7<A,B,C,D,E,F,G> g(G g)
      Static factory method for wrapping a value of type G in a Choice7.
      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
      Parameters:
      g - the value
      Returns:
      the wrapped value as a Choice7<A, B, C, D, E, F, G>
    • pureChoice

      public static <A, B, C, D, E, F> Pure<Choice7<A,B,C,D,E,F,?>> pureChoice()
      The canonical Pure instance for Choice7.
      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
      Returns:
      the Pure instance