map2K<A, B, R> function

Option<R> Function(Option<A> optionA) map2K<A, B, R>(
  1. Option<B> optionB,
  2. R f(
    1. A a,
    2. B b
    )
)

A wrapper around map2, useful for chaining. The second Option is passed as the first argument.

expect(
  some(1).chain(map2K(some(2), (a, int b) => a + b)),
  some(3),
);
expect(
  some(1).chain(map2K(none(), (a, int b) => a + b)),
  none(),
);

Implementation

Option<R> Function(Option<A> optionA) map2K<A, B, R>(
  Option<B> optionB,
  R Function(A a, B b) f,
) =>
    (optionA) => map2(f)(optionA, optionB);