mapTuple2<A, B, R> function

Option<R> Function(dynamic tuple) mapTuple2<A, B, R>(
  1. R f(
    1. A a,
    2. B b
    )
)

A variant of map2, that accepts the two Option's as a Tuple2.

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

Implementation

Option<R> Function(Tuple2<Option<A>, Option<B>> tuple) mapTuple2<A, B, R>(
  R Function(A a, B b) f,
) =>
    (t) => map2(f)(t.first, t.second);