map3<A, B, C, R> function

Option<R> Function(Option<A> optionA, Option<B> optionB, Option<C> optionC) map3<A, B, C, R>(
  1. R f(
    1. A a,
    2. B b,
    3. C c
    )
)

Creates a function that accepts three Option's, and if they are all Some, then the transformer function is called with the unwrapped values.

final transform = map3((int a, int b, int c) => a + b + c);

expect(transform(some(1), some(2), some(3)), some(6));
expect(transform(some(1), some(2), none()), none());

Implementation

Option<R> Function(
  Option<A> optionA,
  Option<B> optionB,
  Option<C> optionC,
) map3<A, B, C, R>(
  R Function(A a, B b, C c) f,
) =>
    (a, b, c) => a._bindSome(
        (a) => b._bindSome((b) => c._bindSome((c) => some(f(a, b, c)))));