fromNullableK<A, B> function

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

A fromNullable variant that allows for external values to be passed in.

final greaterThanFive = fromNullableK((int i) => i > 5 ? i : null);
expect(
  await greaterThanFive(10)(),
  O.some(10),
);
expect(
  await greaterThanFive(3)(),
  O.none(),
);

Implementation

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