Way back when, now nearly invisible through the mists of time, I made a decision to name my fledgling business “Hylomorphic”. Where did that idea come from?

First of all, it’s just a cool-sounding word that’s a decently unique identifier for a new company. (I know certain people who hate when I qualify “unique”, but oh well.)

Second of all…it’s complicated.

It’s really “A Tale of an Algebra and its Coalgebra”, but that’s not as pithy. We only need F-algebras here, and so instead of getting into (and misrepresenting) the category theory behind this, I’ll just encourage you (and my future self) to read up on that, and give some code. We define an F-algebra

and its F-coalgebra

just like in `Control.Functor.Algebra`

.

Also just like with algebras, I’ll be glossing over what “morphism” means. Let’s say it’s a way for us to transform something into something else, while keeping around some of the structure of the original thing. Vague enough?

There are two kinds of morphisms we need here. The first is a “catamorphism”, commonly called a fold. Recall this definition of sum:

This expresses the key idea behind catamorphisms. We’re taking a big set of results (list of numbers), and reducing it down to one single result (single number) at the end.

We need one more thing to get started: functor fixpoints.

We define catamorphisms like this:

We can also define something called an “anamorphism”. It works the opposite way: it takes a single thing and unspools it into a big list of results. Commonly known as unfold.

So we have our thesis, our unfold, our anamorphism, which builds up a set of results. Then we have our antithesis, our fold, our catamorphism, which takes the set of results and combines them down into one final result. Seems like our synthesis, our unfold-then-fold, our *hylomorphism*, follows pretty naturally.

A hylomorphism is an anamorphism followed by a catamorphism.^{1}

```
hylo :: Functor f =>
Algebra g b ->
(forall c. f c -> g c) ->
Coalgebra f a -> a -> b
hylo f e g = f . e . fmap (hylo f e g) . g
```

So we have the word “hylomorphism”. How do we get “hylomorphic”?

Simple! We take the Greek suffix “-ic” to make words adjectives and swap it in. Why? It sounds cooler, and naming something an “-ism” is a recipe for disaster.

This is not the way I ever actually explain the name to people who ask. (God help them if I ever started doing that….) A more realistic version could be: “It means something that builds up a big set of results and then condenses those down to one final result.”

I messed up the original code here, credit for a correct version goes to Kmett’s Control.Morphism.Hylo↩︎