flatMap<L, R, R2> function

TaskEither<L, R2> Function(TaskEither<L, R> taskEither) flatMap<L, R, R2>(
  1. TaskEither<L, R2> f(
    1. R value
    )
)

If the given TaskEither is an Right, then unwrap the result and transform it into another TaskEither.

expect(
  await right(123).chain(flatMap((i) => right('got: $i')))(),
  E.right('got: 123'),
);
expect(
  await right(123).chain(flatMap((i) => left('fail')))(),
  E.left('fail'),
);

Implementation

TaskEither<L, R2> Function(TaskEither<L, R> taskEither) flatMap<L, R, R2>(
  TaskEither<L, R2> Function(R value) f,
) =>
    (fa) => TaskEither(
          fa.p(task.flatMap(either.fold((_) => left<L, R2>(_), f))),
        );