foldr' is a variant of
foldr that performs strict
reduction from right to left, i.e. starting with the right-most
element. The input structure
must be finite, otherwise
foldr' runs out of space (
diverges).
If you want a strict right fold in constant space, you need a
structure that supports faster than
O(n) access to the
right-most element, such as
Seq from the
containers
package.
This method does not run in constant space for structures such as
lists that don't support efficient right-to-left iteration and so
require
O(n) space to perform right-to-left reduction. Use of
this method with such a structure is a hint that the chosen structure
may be a poor fit for the task at hand. If the order in which the
elements are combined is not important, use
foldl' instead.