Is a set fold a catamorphism ? or an hylomorphism?

225 Views Asked by At

Considering the definition of catamorphism, I wonder whether a (finite) set fold (e.g. in Haskell here or here) is a catamorphism and for which F-algebra.

Indeed, it seems that a set would need to be deconstructed via a disjoint union in order to define an F-algebra homomorphism.

More precisely, if I consider the category of sets, a set $S$ and the functor $F$ sending a set $A$ over $S \times A + 1$, an $F$-algebra is a set $A$ together with a function $\alpha$ from $S \times A + 1$ to $A$, or equivalently a function $\alpha_1$ from $S \times A$ to $A$ and an element $\alpha_2$ in $A$.

But in this case, the initial $F$-algebra carrier seems to be the underlying set $S^*$ of the free monoid associated with $S$, i.e. the set of lists of elements in $S$.

Is it possible to define the finite set fold as a catamorphism ?

Or is the finite set fold a list fold (resp. a tree fold) because a set is represented as a finite list (resp. a tree) ?

Edit: From the previous point, it seems that in fact, the function from a finite set to a list (resp. to a tree) would be an anamorphism and therefore the set fold would be an hylomorphism. Is this correct ?