Category Theory for Programmers
《面向程序员的范畴论》是Bartosz Milewski写的一系列文章,向程序员介绍范畴论的一些概念,并以代码进行概念演示。
该系列博客被整理成一个Github仓库,用于生成可下载PDF,并加入其它语言的代码样例。
国内也有大神对系列博客的第一部分进行了翻译。
这一博客系列整理为阅读笔记,期望能在读完之后对范畴论能有自己的理解。
作者博客:Bartosz Milewski’s Programming Cafe
作者的YouTube:Bartosz Milewski
作者的讲解视频:Bartosz Milewski’s YouTube playlists (Category Theory videos)
CTFP-PDF:hmemcpy/milewski-ctfp-pdf
中文译者个人首页:garfileo - SegmentFault
一些有趣的文章:
阅读笔记
本部分阅读笔记是对于翻译版和原文的对照阅读进行记录,后期比较草率。翻译版本仅第一部分,已重新写了其他笔记,并对内容进行了理解和延申
- Category: The Essence of Composition
- Types and Functions
- Categories Great and Small
- Kleisli Categories
- Products and Coproducts
- Simple Algebraic Data Type
- Functors
- Functoriality
- Function Type
- Natural Transformations
Table of Contents
Part One
- Category: The Essence of Composition
- Types and Functions
- Categories Great and Small
- Kleisli Categories
- Products and Coproducts
- Simple Algebraic Data Types
- Functors
- Functoriality
- Function Types
- Natural Transformations
Part Two
- Category Theory and Declarative Programming
- Limits and Colimits
- Free Monoids
- Representable Functors
- The Yoneda Lemma
- Yoneda Embedding
Part Three
- It’s All About Morphisms
- Adjunctions
- Free/Forgetful Adjunctions
- Monads: Programmer’s Definition
- Monads and Effects
- Monads Categorically
- Comonads
- F-Algebras
- Algebras for Monads
- Ends and Coends
- Kan Extensions
- Enriched Categories
- Topoi
- Lawvere Theories
- Monads, Monoids, and Categories
中文翻译版
第一部分
- <译> 范畴:复合的本质
- <译> 类型与函数
- <译> 范畴,可大可小
- <译> Kleisli 范畴
- <译> 积与余积
- <译> 简单的代数数据类型
- <译> 函子
- <译> 函子性
- <译> 函数类型
- <译> 自然变换
YouTube Videos
there are 3 playlists.
Category Theory
- Category Theory 1.1: Motivation and Philosophy
- Category Theory 1.2: What is a category?
- Category Theory 2.1: Functions, epimorphisms
- Category Theory 2.2: Monomorphisms, simple types
- Category Theory 3.1: Examples of categories, orders, monoids
- Category Theory 3.2: Kleisli category
- Category Theory 4.1: Terminal and initial objects
- Category Theory 4.2: Products
- Category Theory 5.1: Coproducts, sum types
- Category Theory 5.2: Algebraic data types
- Category Theory 6.1: Functors
- Category Theory 6.2: Functors in programming
- Category Theory 7.1: Functoriality, bifunctors
- Category Theory 7.2: Monoidal Categories, Functoriality of ADTs, Profunctors
- Category Theory 8.1: Function objects, exponentials
- Category Theory 8.2: Type algebra, Curry-Howard-Lambek isomorphism
- Category Theory 9.1: Natural transformations
- Category Theory 9.2: bicategories
- Category Theory 10.1: Monads
- Category Theory 10.2: Monoid in the category of endofunctors
Category Theory II
- Category Theory II 1.1: Declarative vs Imperative Approach
- Category Theory II 1.2: Limits
- Category Theory II 2.1: Limits, Higher order functors
- Category Theory II 2.2: Limits, Naturality
- Category Theory II 3.1: Examples of Limits and Colimits
- Category Theory II 3.2: Free Monoids
- Category Theory II 4.1: Representable Functors
- Category Theory II 4.2: The Yoneda Lemma
- Category Theory II 5.1: Yoneda Embedding
- Category Theory II 5.2: Adjunctions
- Category Theory II 6.1: Examples of Adjunctions
- Category Theory II 6.2: Free-Forgetful Adjunction, Monads from Adjunctions
- Category Theory II 7.1: Comonads
- Category Theory II 7.2: Comonads Categorically and Examples
- Category Theory II 8.1: F-Algebras, Lambek’s lemma
- Category Theory II 8.2: Catamorphisms and Anamorphisms
- Category Theory II 9.1: Lenses
- Category Theory II 9.2: Lenses categorically
Category Theory III
- Category Theory III 1.1: Overview part 1
- Category Theory III 1.2: Overview part 2
- Category Theory III 2.1: String Diagrams part 1
- Category Theory III 2.2, String Diagrams part 2
- Category Theory III 3.1, Adjunctions and monads
- Category Theory III 3.2, Monad Algebras
- Category Theory III 4.1, Monad algebras part 2
- Category Theory III 4.2, Monad algebras part 3
- Category Theory III 5.1, Eilenberg Moore and Lawvere
- Category Theory III 5.2, Lawvere Theories
- Category Theory III 6.1, Profunctors
- Category Theory III 6.2, Ends
- Category Theory III 7.1, Natural transformations as ends
- Category Theory III 7.2, Coends
Table of Contents in Detail
The Preface
Part One
- Category: The Essence of Composition
- Arrows as Functions
- Properties of COmposition
- Composition is the Essence of Programming
- Challenges
- Types and Functions
- Who Needs Types?
- Types Are About Composability
- What Are Types?
- Why Do We Need a Mathematical Model?
- Pure and Dirty Functions
- Examples of Types
- Challenges
- Categories Great and Small
- No Objects
- Simple Graphs
- Orders
- Monoid as Set
- Monoid as Category
- Challenges
- Kleisli Categories
- The Writer Category
- Writer in Haskell
- Kleisli Categories
- Challenges
- Products and Coproducts
- Initial Object
- Terminal Object
- Duality
- Isomorphisms
- Products
- Coproduct
- Asymmetry
- Challenges
- Bibliography
- Simple Algebraic Data Types
- Product Types
- Records
- Sum Types
- Algebra Types
- Challenges
- Functors
- Functors in Programming
- The Maybe Functor
- Equational Reasoning
- Optional
- Typeclasses
- Functor in C++
- The List Functor
- The Reader Functor
- Functors as Containers
- Functor Composition
- Challenges
- Functors in Programming
- Functoriality
- Bifuncotrs
- Product and Coproduct Bifunctors
- Functorial Algebraic Data Types
- Functors in C++
- The Writer Functor
- Covariant and Contravariant Functors
- Profunctors
- The Hom-Functor
- Challenges
- Function Types
- Universal Construction
- Curring
- Exponentials
- Cartesian Closed Categories
- Exponentials and Algebraic Data Types
- Zeroth Power
- Powers of One
- First Power
- Exponentials of Sums
- Exponentials of Exponentials
- Exponentials over Products
- Curry-Howard Isomorphism
- Bibliography
- Natural Transformations
- Polymorphic Functions
- Beyond Naturality
- Functor Category
- 2-Categories
- Conclusion
- Challenges
Part Two
- Declarative Programming
- Limits and Colimits
- Limit as Natural Isomorphism
- Examples of Limits
- Colimits
- Continuity
- Challenges
- Free Monoids
- Free Monoid in Haskell
- Free Monoid Universal Construction
- Challenges
- Representable Functors
- The Hom Functor
- Representable Functors
- Challenges
- Bibliography
- The Yoneda Lemma
- Yoneda in Haskell
- Co-Yoneda
- Challenges
- Bibliography
- Yoneda Embedding
- The Embedding
- Application to Haskell
- Preorder Example
- Naturality
- Challenges
Part Three
- It’s All About Morphisms
- Functors
- Commuting Diagrams
- Natural Transformations
- Natural Isomorphisms
- Hom-Sets
- Hom-set Isomorphisms
- Asymmetry of Hom-Sets
- Challenges
- Adjunctions
- Adjunction and Unit/Counit Pair
- Adjunction and Hom-Sets
- Product from Adjunction
- Exponential from Adjunction
- Challenges
- Free/Forgetful Adjunctions
- Some Intuitions
- Challenges
- Monads: Programmer’s Definition
- The Klesli Category
- Fish Anatomy
- The do Notation
- Monads and Effects
- The Problem
- The Solution
- Partiality
- Nondeterminism
- Read-Only State
- Write-Only State
- State
- Exceptions
- Continuations
- Interactive Input
- Interactive Output
- Conclusion
- Monads Categorically
- Monoidal Categories
- Monoid in a Monoidal Category
- Monads as Monoids
- Monads from Adjunctions
- Comonads
- Programming with Comonads
- The Product Comonad
- Dissecting the Composition
- The Stream Comonad
- Comonad Categorically
- The Store Comonad
- Challenges
- F-Algebras
- Recursion
- Category of F-Algebras
- Natural Numbers
- Catamorphisms
- Folds
- Coalgebras
- Challenges
- Algebras for Monads
- T-algebras
- The Kleisli Category
- Coalgebras for Comonads
- Lenses
- Challenges
- Ends and Coends
- Dinatural Transformations
- Ends
- Ends as Equalizers
- Natural Transformations as Ends
- Coends
- Ninja Yoneda Lemma
- Profunctor Composition
- Kan Extensions
- Right Kan Extension
- Kan Extension as Adjunction
- Left Kan Extension
- Kan Extensions as Ends
- Kan Extensions in Haskell
- Free Functor
- Enriched Categories
- Why Monoidal Category?
- Monoidal Category
- Enriched Category
- Preorders
- Metric Spaces
- Enriched Functors
- Self Enrichment
- Relation to 2-Categories
- Topoi
- Subobject Classifier
- Topos
- Topoi and Logic
- Challenges
- Lawvere Theories
- Universal Algebra
- Lawvere Theories
- Models of Lawvere Theories
- The Theory of Monoids
- Lawvere Theories and Monads
- Monads as Coends
- Lawvere Theory of Side Effects
- Challenges
- Further Reading
- Monads, Monoids, and Categories
- Bicategories
- Monads
- Challenges
- Bibliography