chainNullableK<A, B> function

TaskOption<B> Function(TaskOption<A> value) chainNullableK<A, B>(
  1. B? f(
    1. A a
    )
)

A chainable fromNullable variant that transforms the given TaskOption into a nullable value, then flattens the result.

expect(
  await some('hello').chain(chainNullableK((s) => '$s world'))(),
  O.some('hello world'),
);
expect(
  await some('hello').chain(chainNullableK((s) => null))(),
  O.none(),
);

Implementation

TaskOption<B> Function(TaskOption<A> value) chainNullableK<A, B>(
  B? Function(A a) f,
) =>
    flatMap(fromNullableK(f));