xxleyi / learning_list

聚集自己的学习笔记
11 stars 3 forks source link

let us dive into functional programming #182

Open xxleyi opened 5 years ago

xxleyi commented 5 years ago

Faulty Assumptions: Things I wish someone had explained about functional programming

函数式编程的三个基本点并没有高深的理论:

开始理解并接受上述三点,并不算困难,更多的是 unlearn 的过程,去掉旧有的刻板认知即可。

但真正以函数式为核心的编程项目将不可避免的使用或涉及到一些更高级概念,比如:

  1. algebraic structures (pattern of type)
  2. type classes (type of type, used to implement algebraic structure )
  3. algebraic data types (sum or product of multi types, very easy to match)
  4. monad (one of algebraic structures which can handle effects)

记住,在函数式编程中,不需要 class 这个概念,只需要 type 即可,type 是所有语言通用的抽象,用以指代特定的数据集合。

延伸开来,class 也不是面向对象中必不可少的元素,像 Golang,就完全没有 class。

xxleyi commented 5 years ago

Algebraic Structures: Things I wish someone had explained about functional programming

通篇看下来,对理解代数结构很有助益,虽然作者举了很多形象化的例子,但我倒是对那个最抽象的数学化的定义最有好感:

In mathematics, and more specifically in abstract algebra, an algebraic structure on a set AA (called carrier set or underlying set) is a collection of finitary operations on AA; the set AA with this structure is also called an algebra.

xxleyi commented 5 years ago

Type Classes: Things I wish someone had explained about functional programming

一句话:Type Class 是某些语言提供的 feature,主要用途是可以便利的实现代数结构。

xxleyi commented 5 years ago

Adventures in Abstract Algebra Part I: Implementing Algebraic Structures in Scala · An Abstract Plane

这个系列也很棒,可以照着代码过一遍,非常棒的具像化。