Users can ignore this method.
Users can ignore this method. It is exposed so library authors can run folds over their own sequence types.
"build" constructs a FoldState, which tells us how to run the fold. It is expected that we can run the same Fold many times over different data structures, but we must build a new FoldState every time.
See FoldState for information on how to use this for your own sequence types.
Transforms the input of the fold before every accumulation.
Transforms the input of the fold before every accumulation. (The name comes from "contravariant map.") This is analogous to "Function1.andThen."
Convenient shorthand for joining Folds without combining at the end.
Joins two folds into one and combines the results.
Joins two folds into one and combines the results. The fused fold accumulates with both at the same time and combines at the end.
Transforms the output of the Fold after iteration is complete.
Transforms the output of the Fold after iteration is complete. This is analogous to "Future.map" or "Function1.compose."
Trivially runs a Fold over an empty sequence.
Trivially runs a Fold over a single element sequence.
Runs a Fold over a Traversable.
Folds are first-class representations of "Traversable.foldLeft." They have the nice property that they can be fused to work in parallel over an input sequence.
A Fold accumulates inputs (I) into some internal type (X), converting to a defined output type (O) when done. We use existential types to hide internal details and to allow for internal and external (X and O) types to differ for "map" and "join."
In discussing this type we draw parallels to Function1 and related types. You can think of a fold as a function "Seq[I] => O" but in reality we do not have to materialize the input sequence at once to "run" the fold.
The traversal of the input data structure is NOT done by Fold itself. Instead we expose some methods like "overTraversable" that know how to iterate through various sequence types and drive the fold. We also expose some internal state so library authors can fold over their own types.
See the companion object for constructors.