flatMap<A, B> function

Task<B> Function(Task<A> task) flatMap<A, B>(
  1. Task<B> f(
    1. A value
    )
)

Transforms a value from a Task into another Task, then flattens the result.

expect(
  await fromThunk(() => 'hi')
      .chain(flatMap((s) => fromThunk(() => s.toUpperCase())))(),
  equals('HI'),
);

Implementation

Task<B> Function(Task<A> task) flatMap<A, B>(Task<B> Function(A value) f) =>
    (t) => Task(() => t().flatMap((v) => f(v)()));