alt<L, R> function

TaskEither<L, R> Function(TaskEither<L, R> taskEither) alt<L, R>(
  1. TaskEither<L, R> orElse(
    1. L left
    )
)

If the given TaskEither is an Left, then unwrap the result and transform it into an alternative 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, R> Function(TaskEither<L, R> taskEither) alt<L, R>(
  TaskEither<L, R> Function(L left) orElse,
) =>
    (fa) => TaskEither(
          fa.p(task.flatMap(either.fold(orElse, (_) => right<L, R>(_)))),
        );