Left-associative fold of a structure, lazy in the accumulator. This is
rarely what you want, but can work well for structures with efficient
right-to-left sequencing and an operator that is lazy in its left
argument.
In case of
NonEmpty lists,
foldlMap1, when given a
function
f, a binary operator
g, and a list, reduces
the list using
g from left to right applying
f to
the leftmost element:
foldlMap1 f g (x1 :| [x2, ..., xn]) == (...(((f x1) `g` x2) `g`...) `g` xn
Note that to produce the outermost application of the operator the
entire input list must be traversed. This means that
foldlMap1
will diverge if given an infinite list.
If you want an efficient strict left-fold, you probably want to use
foldlMap1' instead of
foldlMap1. The reason for this is
that the latter does not force the
inner results (e.g.
(f
x1) `g` x2 in the above example) before applying them to the
operator (e.g. to
(`g` x3)). This results in a thunk chain
<math> elements long, which then must be evaluated from the
outside-in.
For a general
Foldable1 structure this should be semantically
identical to:
foldlMap1 f g = foldlMap1 f g . toNonEmpty