Esempio n. 1
0
 @Override
 public <A> Either<S, A> mplus(_<__.µ<Either.µ, S>, A> one, _<__.µ<Either.µ, S>, A> two) {
     Either<S,A> first = Either.narrow(one);
     Either<S,A> second = Either.narrow(two);
     if (first.isLeft()) {
         return second.isRight() ? second :  Either.newLeft(monoid.apply(first.getLeft(), second.getLeft()));
     } else {
         return second.isLeft() || bias == Bias.FIRST_RIGHT ? first : second;
     }
 }
Esempio n. 2
0
 public default <A, B> B foldMap(final Monoid<B> mb, final Function<A, B> fn, _<F, A> nestedA) {
     return foldr((A a) -> b -> mb.apply(fn.apply(a), b), mb.identity(), nestedA);
 }