foldMap<B> method

B foldMap<B>(
  1. Monoid<B> monoid,
  2. B f(
    1. A a
    )
)

Fold implemented by mapping A values into B and then combining them using the given Monoid<B> instance.

Use Monoid<B> to provide the initial value of the fold (empty) and the combine function to combine the accumulator B with the value of type B computed using the function f from type A (f(a)).

Implementation

B foldMap<B>(Monoid<B> monoid, B Function(A a) f) =>
    foldRight(monoid.empty, (b, a) => monoid.combine(f(a), b));