Skip to content
Merged
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
13 changes: 13 additions & 0 deletions core/src/main/java/fj/data/Either.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,19 @@ public final <X> X either(final F<A, X> left, final F<B, X> right) {
right.f(right().value());
}

/**
* Map the given functions across the appropriate side.
*
* @param left The function to map if this is left.
* @param right The function to map if this is right.
* @return A new either value after mapping with the appropriate function applied.
*/
public final <X, Y> Either<X, Y> bimap(final F<A, X> left, final F<B, Y> right) {
return isLeft() ?
left(left.f(left().value())) :
right(right.f(right().value()));
}

@Override
public boolean equals(Object other) {

Expand Down