范畴论笔记 - 序

CTFP博客系列及视频笔记,序章

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

一些有趣的文章:

单子,想弄不懂都很难


阅读笔记

本部分阅读笔记是对于翻译版和原文的对照阅读进行记录,后期比较草率。翻译版本仅第一部分,已重新写了其他笔记,并对内容进行了理解和延申

  1. Category: The Essence of Composition
  2. Types and Functions
  3. Categories Great and Small
  4. Kleisli Categories
  5. Products and Coproducts
  6. Simple Algebraic Data Type
  7. Functors
  8. Functoriality
  9. Function Type
  10. Natural Transformations

以上Markdown文件链接可能失效,可以查看系列Part-1Part-2

Table of Contents

The Preface

Part One

  1. Category: The Essence of Composition
  2. Types and Functions
  3. Categories Great and Small
  4. Kleisli Categories
  5. Products and Coproducts
  6. Simple Algebraic Data Types
  7. Functors
  8. Functoriality
  9. Function Types
  10. Natural Transformations

Part Two

  1. Category Theory and Declarative Programming
  2. Limits and Colimits
  3. Free Monoids
  4. Representable Functors
  5. The Yoneda Lemma
  6. Yoneda Embedding

Part Three

  1. It’s All About Morphisms
  2. Adjunctions
  3. Free/Forgetful Adjunctions
  4. Monads: Programmer’s Definition
  5. Monads and Effects
  6. Monads Categorically
  7. Comonads
  8. F-Algebras
  9. Algebras for Monads
  10. Ends and Coends
  11. Kan Extensions
  12. Enriched Categories
  13. Topoi
  14. Lawvere Theories
  15. Monads, Monoids, and Categories

中文翻译版

<译> 写给程序猿的范畴论 · 序

第一部分

  1. <译> 范畴:复合的本质
  2. <译> 类型与函数
  3. <译> 范畴,可大可小
  4. <译> Kleisli 范畴
  5. <译> 积与余积
  6. <译> 简单的代数数据类型
  7. <译> 函子
  8. <译> 函子性
  9. <译> 函数类型
  10. <译> 自然变换

YouTube Videos

there are 3 playlists.

Category Theory

  1. Category Theory 1.1: Motivation and Philosophy
  2. Category Theory 1.2: What is a category?
  3. Category Theory 2.1: Functions, epimorphisms
  4. Category Theory 2.2: Monomorphisms, simple types
  5. Category Theory 3.1: Examples of categories, orders, monoids
  6. Category Theory 3.2: Kleisli category
  7. Category Theory 4.1: Terminal and initial objects
  8. Category Theory 4.2: Products
  9. Category Theory 5.1: Coproducts, sum types
  10. Category Theory 5.2: Algebraic data types
  11. Category Theory 6.1: Functors
  12. Category Theory 6.2: Functors in programming
  13. Category Theory 7.1: Functoriality, bifunctors
  14. Category Theory 7.2: Monoidal Categories, Functoriality of ADTs, Profunctors
  15. Category Theory 8.1: Function objects, exponentials
  16. Category Theory 8.2: Type algebra, Curry-Howard-Lambek isomorphism
  17. Category Theory 9.1: Natural transformations
  18. Category Theory 9.2: bicategories
  19. Category Theory 10.1: Monads
  20. Category Theory 10.2: Monoid in the category of endofunctors

Category Theory II

  1. Category Theory II 1.1: Declarative vs Imperative Approach
  2. Category Theory II 1.2: Limits
  3. Category Theory II 2.1: Limits, Higher order functors
  4. Category Theory II 2.2: Limits, Naturality
  5. Category Theory II 3.1: Examples of Limits and Colimits
  6. Category Theory II 3.2: Free Monoids
  7. Category Theory II 4.1: Representable Functors
  8. Category Theory II 4.2: The Yoneda Lemma
  9. Category Theory II 5.1: Yoneda Embedding
  10. Category Theory II 5.2: Adjunctions
  11. Category Theory II 6.1: Examples of Adjunctions
  12. Category Theory II 6.2: Free-Forgetful Adjunction, Monads from Adjunctions
  13. Category Theory II 7.1: Comonads
  14. Category Theory II 7.2: Comonads Categorically and Examples
  15. Category Theory II 8.1: F-Algebras, Lambek’s lemma
  16. Category Theory II 8.2: Catamorphisms and Anamorphisms
  17. Category Theory II 9.1: Lenses
  18. Category Theory II 9.2: Lenses categorically

Category Theory III

  1. Category Theory III 1.1: Overview part 1
  2. Category Theory III 1.2: Overview part 2
  3. Category Theory III 2.1: String Diagrams part 1
  4. Category Theory III 2.2, String Diagrams part 2
  5. Category Theory III 3.1, Adjunctions and monads
  6. Category Theory III 3.2, Monad Algebras
  7. Category Theory III 4.1, Monad algebras part 2
  8. Category Theory III 4.2, Monad algebras part 3
  9. Category Theory III 5.1, Eilenberg Moore and Lawvere
  10. Category Theory III 5.2, Lawvere Theories
  11. Category Theory III 6.1, Profunctors
  12. Category Theory III 6.2, Ends
  13. Category Theory III 7.1, Natural transformations as ends
  14. Category Theory III 7.2, Coends

Table of Contents in Detail

The Preface

Part One

  1. Category: The Essence of Composition
    1. Arrows as Functions
    2. Properties of COmposition
    3. Composition is the Essence of Programming
    4. Challenges
  2. Types and Functions
    1. Who Needs Types?
    2. Types Are About Composability
    3. What Are Types?
    4. Why Do We Need a Mathematical Model?
    5. Pure and Dirty Functions
    6. Examples of Types
    7. Challenges
  3. Categories Great and Small
    1. No Objects
    2. Simple Graphs
    3. Orders
    4. Monoid as Set
    5. Monoid as Category
    6. Challenges
  4. Kleisli Categories
    1. The Writer Category
    2. Writer in Haskell
    3. Kleisli Categories
    4. Challenges
  5. Products and Coproducts
    1. Initial Object
    2. Terminal Object
    3. Duality
    4. Isomorphisms
    5. Products
    6. Coproduct
    7. Asymmetry
    8. Challenges
    9. Bibliography
  6. Simple Algebraic Data Types
    1. Product Types
    2. Records
    3. Sum Types
    4. Algebra Types
    5. Challenges
  7. Functors
    1. Functors in Programming
      1. The Maybe Functor
      2. Equational Reasoning
      3. Optional
      4. Typeclasses
      5. Functor in C++
      6. The List Functor
      7. The Reader Functor
    2. Functors as Containers
    3. Functor Composition
    4. Challenges
  8. Functoriality
    1. Bifuncotrs
    2. Product and Coproduct Bifunctors
    3. Functorial Algebraic Data Types
    4. Functors in C++
    5. The Writer Functor
    6. Covariant and Contravariant Functors
    7. Profunctors
    8. The Hom-Functor
    9. Challenges
  9. Function Types
    1. Universal Construction
    2. Curring
    3. Exponentials
    4. Cartesian Closed Categories
    5. Exponentials and Algebraic Data Types
      1. Zeroth Power
      2. Powers of One
      3. First Power
      4. Exponentials of Sums
      5. Exponentials of Exponentials
      6. Exponentials over Products
    6. Curry-Howard Isomorphism
    7. Bibliography
  10. Natural Transformations
    1. Polymorphic Functions
    2. Beyond Naturality
    3. Functor Category
    4. 2-Categories
    5. Conclusion
    6. Challenges

Part Two

  1. Declarative Programming
  2. Limits and Colimits
    1. Limit as Natural Isomorphism
    2. Examples of Limits
    3. Colimits
    4. Continuity
    5. Challenges
  3. Free Monoids
    1. Free Monoid in Haskell
    2. Free Monoid Universal Construction
    3. Challenges
  4. Representable Functors
    1. The Hom Functor
    2. Representable Functors
    3. Challenges
    4. Bibliography
  5. The Yoneda Lemma
    1. Yoneda in Haskell
    2. Co-Yoneda
    3. Challenges
    4. Bibliography
  6. Yoneda Embedding
    1. The Embedding
    2. Application to Haskell
    3. Preorder Example
    4. Naturality
    5. Challenges

Part Three

  1. It’s All About Morphisms
    1. Functors
    2. Commuting Diagrams
    3. Natural Transformations
    4. Natural Isomorphisms
    5. Hom-Sets
    6. Hom-set Isomorphisms
    7. Asymmetry of Hom-Sets
    8. Challenges
  2. Adjunctions
    1. Adjunction and Unit/Counit Pair
    2. Adjunction and Hom-Sets
    3. Product from Adjunction
    4. Exponential from Adjunction
    5. Challenges
  3. Free/Forgetful Adjunctions
    1. Some Intuitions
    2. Challenges
  4. Monads: Programmer’s Definition
    1. The Klesli Category
    2. Fish Anatomy
    3. The do Notation
  5. Monads and Effects
    1. The Problem
    2. The Solution
      1. Partiality
      2. Nondeterminism
      3. Read-Only State
      4. Write-Only State
      5. State
      6. Exceptions
      7. Continuations
      8. Interactive Input
      9. Interactive Output
    3. Conclusion
  6. Monads Categorically
    1. Monoidal Categories
    2. Monoid in a Monoidal Category
    3. Monads as Monoids
    4. Monads from Adjunctions
  7. Comonads
    1. Programming with Comonads
    2. The Product Comonad
    3. Dissecting the Composition
    4. The Stream Comonad
    5. Comonad Categorically
    6. The Store Comonad
    7. Challenges
  8. F-Algebras
    1. Recursion
    2. Category of F-Algebras
    3. Natural Numbers
    4. Catamorphisms
    5. Folds
    6. Coalgebras
    7. Challenges
  9. Algebras for Monads
    1. T-algebras
    2. The Kleisli Category
    3. Coalgebras for Comonads
    4. Lenses
    5. Challenges
  10. Ends and Coends
    1. Dinatural Transformations
    2. Ends
    3. Ends as Equalizers
    4. Natural Transformations as Ends
    5. Coends
    6. Ninja Yoneda Lemma
    7. Profunctor Composition
  11. Kan Extensions
    1. Right Kan Extension
    2. Kan Extension as Adjunction
    3. Left Kan Extension
    4. Kan Extensions as Ends
    5. Kan Extensions in Haskell
    6. Free Functor
  12. Enriched Categories
    1. Why Monoidal Category?
    2. Monoidal Category
    3. Enriched Category
    4. Preorders
    5. Metric Spaces
    6. Enriched Functors
    7. Self Enrichment
    8. Relation to 2-Categories
  13. Topoi
    1. Subobject Classifier
    2. Topos
    3. Topoi and Logic
    4. Challenges
  14. Lawvere Theories
    1. Universal Algebra
    2. Lawvere Theories
    3. Models of Lawvere Theories
    4. The Theory of Monoids
    5. Lawvere Theories and Monads
    6. Monads as Coends
    7. Lawvere Theory of Side Effects
    8. Challenges
    9. Further Reading
  15. Monads, Monoids, and Categories
    1. Bicategories
    2. Monads
    3. Challenges
    4. Bibliography