flatMap<A, B> function

Option<B> Function(Option<A> option) flatMap<A, B>(
  1. Option<B> f(
    1. A value
    )
)

Transform the Option into another Option, using the given function.

expect(
  some(1).chain(flatMap((i) => some(i + 2))),
  some(3),
);
expect(
  some(1).chain(flatMap((i) => none())),
  none(),
);

Implementation

Option<B> Function(Option<A> option) flatMap<A, B>(
  Option<B> Function(A value) f,
) =>
    (o) => o._bindSome(f);