flatMapFirst<L, R> function
TaskEither<L, R> Function(TaskEither<L, R> taskEither)
flatMapFirst<L, R>(
- TaskEither<
L, dynamic> f(- R value
If the given TaskEither is an Right, then unwrap the result and transform it into another TaskEither - but only keep Left results.
expect(
await right(123).chain(flatMapFirst((i) => right('got: $i')))(),
E.right(123),
);
expect(
await right(123).chain(flatMapFirst((i) => left('fail')))(),
E.left('fail'),
);
Implementation
TaskEither<L, R> Function(TaskEither<L, R> taskEither) flatMapFirst<L, R>(
TaskEither<L, dynamic> Function(R value) f,
) =>
flatMap((r) => f(r).chain(map((_) => r)));