Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public Maybe<A> checkedApply(Maybe<A> maybeX, Maybe<A> maybeY) {
@Override
public Maybe<A> foldLeft(Maybe<A> acc, Iterable<Maybe<A>> maybes) {
return trampoline(
into((res, it) -> res.equals(nothing())
into((res, it) -> res.equals(nothing()) || !it.hasNext()
? terminate(res)
: recurse(tuple(liftA2(aSemigroup, res, it.next()), it))),
tuple(acc, maybes.iterator()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,13 @@ public void foldLeftShortCircuit() {
assertEquals(nothing(), result);
}

@Test
public void foldLeftWorksForJusts() {
Maybe<Unit> result = Absent.<Unit>absent(Constantly::constantly)
.foldLeft(just(UNIT), Arrays.asList(just(UNIT), just(UNIT)));
assertEquals(just(UNIT), result);
}

@Test(timeout = 200)
public void checkedApplyFoldRightShortCircuit() {
Maybe<Unit> result = Absent.<Unit>absent().checkedApply(Constantly::constantly)
Expand Down