Foldable type class represents data structures that can be folded to a summary value.
This interface provides the universal fold operations (foldLeft, foldRight) that work
consistently across all data structures. The fold method is intentionally excluded
because it has different semantics for sum types vs collections:
Sum types (Option, Either, Try): fold(onEmpty, onValue) — pattern match
Foldable type class represents data structures that can be folded to a summary value.
This interface provides the universal fold operations (foldLeft, foldRight) that work consistently across all data structures. The
foldmethod is intentionally excluded because it has different semantics for sum types vs collections:fold(onEmpty, onValue)— pattern matchfold(initial, fn)— left-reduce accumulatorEach type category defines its own
foldwith the appropriate signature.