flatMap<L, R, NR> function
Transforms Right values with the given function, that returns another Either. The resulting Either is then flattened / replaces the existing value.
expect(
right('hello').chain(flatMap((s) => right('$s world!'))),
right('hello world!'),
);
expect(
right('hello').chain(flatMap((s) => left('fail'))),
left('fail'),
);
Implementation
Either<L, NR> Function(Either<L, R> either) flatMap<L, R, NR>(
Either<L, NR> Function(R value) f,
) =>
fold(left, f);