Hylomorphism (or hylemorphism) is a philosophical theory developed by Aristotle, which conceives being (ousia) as a compound of matter and form.
The word is a 19th-century term formed from the Greek words ὕλη hyle, "wood, matter" and μορφή, morphē, "form."
Aristotle defines X's matter as "that out of which" X is made. For example, letters are the matter of syllables. Thus, "matter" is a relative term: an object counts as matter relative to something else. For example, clay is matter relative to a brick because a brick is made of clay, whereas bricks are matter relative to a brick house.
Change is analyzed as a material transformation: matter is what undergoes a change of form. For example, consider a lump of bronze that's shaped into a statue. Bronze is the matter, and this matter loses one form (that of a lump) and gains a new form (that of a statue).
According to Aristotle's theory of perception, we perceive an object by receiving its form with our sense organs. Thus, forms include complex qualia such as colors, textures, and flavors, not just shapes.
In computer science, and in particular functional programming, a hylomorphism is a recursive function, corresponding to the composition of an anamorphism (which first builds a set of results; also known as 'unfolding') followed by a catamorphism (which then folds these results into a final return value). Fusion of these two recursive computations into a single recursive pattern then avoids building the intermediate data structure. This is an example of deforestation, a program optimization strategy. A related type of function is a metamorphism, which is a catamorphism followed by an anamorphism.
A hylomorphism can be defined in terms of its separate anamorphic and catamorphic parts.
The anamorphic part can be defined in terms of a unary function defining the list of elements in
by repeated application ("unfolding"), and a predicate
providing the terminating condition.
The catamorphic part can be defined as a combination of an initial value for the fold and a binary operator
used to perform the fold.