Foldable is a Haskell type class for structures whose elements can be traversed and reduced. Its minimal definition requires foldr; functions such as null, length, elem, sum, maximum, and minimum can then be derived. section 8.2.1
Folding becomes concrete through familiar structures and tasks:
- A left fold reduces elements from left to right by updating an accumulator. section 8.2.1
- A right fold associates the combining function from the right, although both folds evaluate elements from left to right. section 8.2.1
- Foldable extends the idea beyond lists to structures such as binary trees. section 8.2.1
Candy trails and fold expressions
A candy trail demonstrates folding through collection tasks: selecting fruity candies or retaining only the last five. GHCi examples then show foldl and foldr building visibly different parenthesized expressions from the same numbers.

