I\'m trying to learn about catamorphisms and I\'ve read the Wikipedia article and the first couple posts in the series of the topic for F# on the Inside F# blog. >
I understand that it's a generalization of folds (i.e., mapping a structure of many values to one value, including a list of values to another list).
I wouldn't say one value.It maps it into another structure.
Maybe an example would clarify.let's say summation over a list.
foldr (\x -> \y -> x + y) 0 [1,2,3,4,5]
Now this would reduce to 15. But actually,it can be viewed mapping to a purely syntactic structure 1 + 2 + 3 + 4 + 5 + 0. It is just that the programming language(in the above case,haskell) knows how to reduce the above syntactic structure to 15.
Basically,a catamorphism replaces one data constructor with another one.In case of above list,
[1,2,3,4,5] = 1:2:3:4:5:[] (: is the cons operator,[] is the nil element) the catamorphism above replaced : with + and [] with 0.
It can be generalized to any recursive datatypes.