Type Class

1
2
3
4
5
A type class is a sort of interface that defines some behavior. 
If a type is a part of a typeclass,that means that it supports and implements the behavior the typeclass describes.
A lot of people coming from OOP get confused by type classes because they think they are like classes in object oriented languages.
Well, they're not.
You can think of them kind of as Java interfaces, only better.

TypeClassHaskell 中的概念,TypeClass 是定义公共行为的接口,类似于 Java 中的 InterfaceScala 中的 Trait
TypeClass行为定义具有行为的对象 分离,更容易实现 DuckType; 在函数式编程中,通常将数据与行为相分离,甚至是数据与行为按需绑定,已达到更高级的组合特性。
Scala 使用隐式转换使之能够不那么完美地支持 TypeClass


Monad

Monad 是一种将函子组合应用的方法,经常用来代表计算,用来把与业务无关的通用程序抽象出来。


Reference :

  1. 图解 Monad
  2. Monad (functional programming)
  3. Type与Class、ClassTag与TypeTag