CTFP Ch07 - WinChua/blog GitHub Wiki

概要

之前6章的内容研究的都是单个category上面的一些对象,关系,包括:

  1. category的组成: obj以及arrow
  2. category的规则: obj需要有id morphism; morphism需要能够compose
  3. category研究的是obj以及obj之间的关系: universal construction ==> 1. define pattern; 2. ranking
  4. monoid: 从set角度的定义以及从category角度的定义, 以及两个定义之间的关系
  5. 编程语言中, type以及function构成了set category中的obj以及morphism, 利用universal construction定义了一些对象,包括:initial object, terminal object, product, coproduct
  6. 抽象代数结构

整条路线就是: 先从基本的category的性质开始, 然后讨论编程中的category, 用universal construction描述了一些基本的结构, 通过代数运算构造出其他的复合类型; 这些内容都在单个category中进行讨论的; 第7章开始要讨论的是一些category与category之间的关系, 你可以想象有一个category of all category, 后面要研究的是这个大的category中morphism以及obj的关系,第7章主要研究这个category中的morphism也就是functor

摘录

  • What's a functor? A functor is the arrow between two category(could be the same), a functor not only map object from the source category to the target category, but also morphism. Here is the definition: $$ f :: a \to b \\ F f :: Fa \to Fb $$

  • functor preserver the struct of the source category. by struct , we mean that the composition of morphisms and identity morphism is keep in the target category. $$ g = f . h \\ F g = F f . F h $$

  • functor has the property like function: embed and collapse

  • functor in programming, maybe the same "functor in category of types"

  • serveral example:

    • Maybe functor:
      • $ data\ Maybe = Nothing\ |\ Just\ a $
    • List functor:
    • Reader functor: 这种functor不是容器, 而是一种接收类型参数作为输入, 返回一个返回该类型的函数类型.
  • functor as container:

  • functor don't care about how to extract the value it containes, but focus on the how we can manipulate those value with function. And After all, if we can extract the value it holds, we should see the result of those function.

  • Cat: the category of all categories

    • object: categories
    • morphism: functor
  • how functor compose? what's the identity functor?

随笔