Category Theory may be important to learn as functional programming is coming back into the mainstream. If you a have a passion for discovering abstractions, CT promises to be the ultimate abstraction. In this series of articles I will explain one small concept I have learned in attempt to further my own understanding and hopefully help you learn this vast subject as well.

There are plenty of articles, books, papers etc for learning CT. My goal with these articles is not to provide the best explanation, but rather provide another explanation. An explanation tuned to the way I learn best, metaphors and pictures.

The strategy I recommend for learning CT is to use an introductory book as a guide then consult other resources (YouTube, articles, etc) to chip away at each concept until your understanding is satisfactory and internalized enough to move to the next concept.

Disclaimer: I am not a mathematician and I do not have a degree. I am only just beginning to learn Category Theory and anything I say should be independently verified as correct.

What is Category Theory?

A theory in mathematics is the attempt to seek out patterns and suggest possibilities about these patterns. Then assemble these possibilities into a well-defined set of ideas using mathematical concepts, language, and notation to form statements (axioms) that are taken to be true and built upon to form further axioms.

Category theory is a somewhat special mathematical theory in that the axioms attempt to formalize the structure of all mathematics. the patterns this theory seeks to explain apparently underly every branch of mathematics and more. That is to say, if you were to replace concepts in any branch of mathematics with the most abstract notions of those objects and their rules, you would then be dealing with CT.

What is a Category?

A category has two parts and two rules. A category has things and something-elses. Something-elses can be supplied with a thing and indicate (or point out) the same or another thing and can be combined to form new something-elses.

I use this non-specific language intentionally. It gets difficult to separate the abstract nature of a category from specific examples of a category. For example something-elses are often called functions, as in a mathematical function like f(x), something that takes an input and produces an output. However, something-elses don’t have to be transformations, they only have to be composable. Composable simply means if a something-else points out a thing, that thing (_and any other _thing that something-else might indicate) can be supplied to another something-else that uses things for indicating_._ Another example of what a something-else might represent is a relationship such as ≥.

Simplifying the Language

Objects: things such as real numbers, words, other categories or even arrows

Arrows: something-elses which are composable with associativity. Associativity means you can start following arrows at any point, but you cannot change where they point. The arrows must include at least one identity arrow for every object. An identity arrow is an arrow that indicates the exact object supplied to it.

So using our new language, categories are arrows that use objects to point out other objects of the same kind. These arrows must be associative and composable.

Concept Example

In programming, classes (or more accurately types) are an example of a category. Let’s fill in the blanks:

Category of Types

Objects: Types

Arrows: Hierarchy (inheritance)

Composable: Yes. If type C inherits from type B, and type B inherits from type A, then type C inherits from type A. Notice the order in which these types are defined (evaluated) does not matter from a hierarchy sense i.e. (C <- (B <- A)). However the order in which they are composed does, i.e. C <- B <- A is not the same as B <- C <- A
Identity: Yes. Type A could inherit from type A in which case you would have type A, though since this is trivial no language that I know of supports it.
Category of Metaphors
Objects: anything
Arrows: mental mapping
Composable: Yes. If I imagine a piece of wood represents a boat, and a boat represents travel, I can imagine a piece of wood represents travel.
Identity: Yes. I can always imagine a piece of wood represents a piece of wood.
What’s Next?
The next article will discuss what it means for two categories to be close enough to the same to be considered equal for most intents and purposes.

Link: https://dev.to/chrismcleod/easy-category-theory-part-i-the-basics-nfn