← back to reading

🐱 Category Theory for Programmers

Based on Bartosz Milewski's blog series, licensed CC BY-SA 4.0.

Same format as the paper pages: runnable Python, diagrams, plain English. Milewski wrote for Haskell programmers. These pages translate to Python.

A B f Objects, arrows, composition. That is all of it.
Chapter
1. Category Objects and arrows that compose — the only axioms are identity and associativity 🐱
2. Types and Functions Types are sets, functions are arrows, and Hask is (almost) a category 🐱
3. Categories Great and Small Preorders, monoids, and the thin categories hiding in your code 🐱
4. Kleisli Categories Side effects compose when you change what 'arrow' means 🐱
5. Products and Coproducts Tuples and tagged unions from universal properties alone 🐱
6. Simple Algebraic Data Types Sum types + product types = the algebra of types 🐱
7. Functors Structure-preserving maps between categories — map is a functor 🐱
8. Functoriality Bifunctors, contravariance, and the functor laws your code already obeys 🐱
9. Function Types Exponentials — why a → b is an object in the category 🐱
10. Natural Transformations Polymorphic functions are natural transformations — the parametricity theorem says so 🐱
11. Limits and Colimits The universal cone over a diagram — products and equalizers generalized 🐱
12. Free Monoids Lists are the free monoid — the cheapest way to make concatenation associative 🐱
13. Representable Functors Every container is secretly Hom(A, –) for some A 🐱
14. The Yoneda Lemma An object is determined by how everything maps into it 🐱
15. Yoneda Embedding Every category embeds faithfully into its presheaf category 🐱
16. Adjunctions Free/forgetful, curry/uncurry — two functors that are almost inverses 🐱
17. Monads Kleisli composition — the pattern behind Maybe, List, IO, and probability 🐱
18. Comonads Extract and extend — the dual of monads, hiding in spreadsheets and streams 🐱
19. F-Algebras Recursive data structures as initial algebras — fold is a catamorphism 🐱
20. Ends and Coends Generalized products and sums over functor categories 🐱
21. Kan Extensions The universal construction — everything else is a Kan extension 🐱
22. Enriched Categories When Hom-sets aren't sets — categories enriched over monoidal categories 🐱
23. Topoi A category that acts like a universe of sets — with its own internal logic 🐱
24. Lawvere Theories Algebraic theories as categories — operations are arrows, equations are diagrams 🐱

📺 Video lectures: Bartosz Milewski: Category Theory lectures

Neighbors