forEach<E, L, R, A> static method
{@category collecting}
Implementation
static Effect<E, L, Iterable<R>> forEach<E, L, R, A>(
Iterable<A> iterable,
Effect<E, L, R> Function(A a, int index) f,
) =>
Effect.from(
(context) {
if (iterable.isEmpty) {
return const Right([]);
}
return iterable
.mapWithIndex(f)
.fold<Effect<E, L, Iterable<R>>>(
Effect.succeed(const Iterable.empty()),
(acc, effect) => acc.zipWith(
effect,
(list, r) => list.append(r),
),
)
._unsafeRun(context);
},
);