CTFP Ch02 - WinChua/blog GitHub Wiki

类型与函数概要

第一章中讲到了,编程是为了解决问题,问题的解决方式是将分治,通过将小问题的解组合形成大问题的解。而组合是category theory的本质, 在编程中,我们常常接触到的概念是类型以及函数,我们将某些信息抽象成为某种特定的类型,通过函数在不同的type之间进行操作转换,这跟category中的object以及arrow十分相似。那么type是什么?function又是什么?为什么我们需要type以及function?

摘录

  1. type could be view as a set of value; there is a set category who's object is set;
  2. Set is a very special category. We can peek inside its object and get a lot of intuition to doing that. For example, empty set has no element; one-element set; function map elements from ont set to another set;
  3. Hash category and Set category: difference: Set + bottom = Hash
  4. The property of function Pure and Dirty.
  5. functions that can be implemented by the same formula for any type are called parametrically polymorphic.

随笔

在编程的category, 类型以及函数构成了它的obj以及arrow. 在编程中的类型可以看做是某些value的set, 所有的set构成了Set Category,但这个category还不是编程中研究的category, 由于某一个计算过程可能不会停机, 需要考虑多一种类型--bottom 类型, 用于表示不会停机的类型