Skip to content

Bug in Either.LeftProjection.traverseIO #334

Description

@sidneyquitorio8

There appears to be an issue with Either.LeftProjection.traverseIO. Current implementation is:

      public <C> IO<Either<C, B>> traverseIO(final F<A, IO<C>> f) {
          return e.isRight() ?
                  IOFunctions.map(f.f(value()), Either::<C, B>left) :
                  IOFunctions.unit(Either.right(e.right().value()));
      }

The issue appears to be in the conditional. Instead of checking if its a left & applying the function, it checks if its a right. Doing the following appears to fix this.

      public <C> IO<Either<C, B>> traverseIO(final F<A, IO<C>> f) {
          return e.isLeft() ?
                  IOFunctions.map(f.f(value()), Either::<C, B>left) :
                  IOFunctions.unit(Either.right(e.right().value()));
      }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions