tap<L, R> function

Either<L, R> Function(Either<L, R> either) tap<L, R>(
  1. void f(
    1. R value
    )
)

Perform a side effect on the Either, if it is a Right.

expect(
  right(1).chain(tap(print)), // Prints '1' to the console
  equals(right(1)),
);

Implementation

Either<L, R> Function(Either<L, R> either) tap<L, R>(
  void Function(R value) f,
) =>
    map((r) {
      f(r);
      return r;
    });