chainNullableK<A, B> function
Returns an function that transforms an Option.
If the given transformer returns null
, then None is returned.
expect(
some(10).chain(chainNullableK((i) => i > 5 ? i : null)),
some(10),
);
expect(
some(3).chain(chainNullableK((i) => i > 5 ? i : null)),
none(),
);
Implementation
Option<B> Function(Option<A> option) chainNullableK<A, B>(
B? Function(A value) f,
) =>
flatMap(fromNullableK(f));