Class Coalesce<L,​R>

  • Type Parameters:
    L - the left parameter type
    R - the right parameter type
    All Implemented Interfaces:
    Fn1<java.lang.Iterable<Either<L,​R>>,​Either<java.lang.Iterable<L>,​java.lang.Iterable<R>>>, Applicative<Either<java.lang.Iterable<L>,​java.lang.Iterable<R>>,​Fn1<java.lang.Iterable<Either<L,​R>>,​?>>, Cartesian<java.lang.Iterable<Either<L,​R>>,​Either<java.lang.Iterable<L>,​java.lang.Iterable<R>>,​Fn1<?,​?>>, Cocartesian<java.lang.Iterable<Either<L,​R>>,​Either<java.lang.Iterable<L>,​java.lang.Iterable<R>>,​Fn1<?,​?>>, Contravariant<java.lang.Iterable<Either<L,​R>>,​Profunctor<?,​Either<java.lang.Iterable<L>,​java.lang.Iterable<R>>,​Fn1<?,​?>>>, Functor<Either<java.lang.Iterable<L>,​java.lang.Iterable<R>>,​Fn1<java.lang.Iterable<Either<L,​R>>,​?>>, Profunctor<java.lang.Iterable<Either<L,​R>>,​Either<java.lang.Iterable<L>,​java.lang.Iterable<R>>,​Fn1<?,​?>>, Monad<Either<java.lang.Iterable<L>,​java.lang.Iterable<R>>,​Fn1<java.lang.Iterable<Either<L,​R>>,​?>>, MonadReader<java.lang.Iterable<Either<L,​R>>,​Either<java.lang.Iterable<L>,​java.lang.Iterable<R>>,​Fn1<java.lang.Iterable<Either<L,​R>>,​?>>, MonadRec<Either<java.lang.Iterable<L>,​java.lang.Iterable<R>>,​Fn1<java.lang.Iterable<Either<L,​R>>,​?>>, MonadWriter<java.lang.Iterable<Either<L,​R>>,​Either<java.lang.Iterable<L>,​java.lang.Iterable<R>>,​Fn1<java.lang.Iterable<Either<L,​R>>,​?>>

    public final class Coalesce<L,​R>
    extends java.lang.Object
    implements Fn1<java.lang.Iterable<Either<L,​R>>,​Either<java.lang.Iterable<L>,​java.lang.Iterable<R>>>
    Fold an Iterable<Either<L, R>> into an Either<Iterable<L>, Iterable<R>>, preserving all results of the side that's returned. That is, if the result is a left, it will contain all left values; if it is a right, it will contain all right values.

    It may be useful to think of this as a more efficient version of Merge<Iterable<L>, Iterable<R>>.

    • Field Detail

      • INSTANCE

        private static final Coalesce<?,​?> INSTANCE
    • Constructor Detail

      • Coalesce

        private Coalesce()
    • Method Detail

      • checkedApply

        public Either<java.lang.Iterable<L>,​java.lang.Iterable<R>> checkedApply​(java.lang.Iterable<Either<L,​R>> eithers)
        Description copied from interface: Fn1
        Invoke this function with the given argument, potentially throwing any Throwable.
        Specified by:
        checkedApply in interface Fn1<L,​R>
        Parameters:
        eithers - the argument
        Returns:
        the result of the function application
      • coalesce

        public static <A,​B> Coalesce<A,​B> coalesce()
      • coalesce

        public static <A,​B> Either<java.lang.Iterable<A>,​java.lang.Iterable<B>> coalesce​(java.lang.Iterable<Either<A,​B>> eithers)