chainNullableK<L, R, R2> function
Either<L, R2> Function(Either<L, R> value)
chainNullableK<L, R, R2>(
- R2? f(
- R right
- L orElse(
- R right
A wrapper for fromNullableK, that allows for chaining.
expect(
right('hello').chain(chainNullableK(
(s) => s == 'hello' ? s : null,
() => 'it was not hello',
)),
right('hello'),
);
expect(
right('asdf').chain(chainNullableK(
(s) => s == 'hello' ? s : null,
() => 'it was not hello',
)),
left('it was not hello'),
);
Implementation
Either<L, R2> Function(Either<L, R> value) chainNullableK<L, R, R2>(
R2? Function(R right) f,
L Function(R right) orElse,
) =>
flatMap(fromNullableK(f, orElse));