monad-本质解释- a monad is a design pattern--monad与泛型相关
monad的特征:
类型转化+添加新的操作。
monad RACStream RACSignal RACSubject
monad:单一体,(不可分的)个体
以计算为中心的封装。
In functional programming, a monad is a design pattern that defines how functions, actions, inputs, and outputs can be used together to build generic types,[1] with the following organization:
- Define a data type, and how values of that data type are combined.
- Create functions that use the data type, and compose them together into actions, following the rules defined in the first step.
A monad may encapsulate values of a particular data type, creating a new type associated with a specific additional computation, typically to handle special cases of the type.
//以精准(窄)数据为中心的计算流
Monads allow a programming style where programs are written by putting together highly composable parts, combining in flexible ways the possible actions that can work on a particular type of data. As such, monads have been described as "programmable semicolons"; a semicolon is the operator used to chain together individual statements in many imperative programming languages,[2] thus the expression implies that extra code will be executed between the actions in the pipeline. Monads have also been explained with a physical metaphor as assembly lines, where a conveyor belt transports data between functional units that transform it one step at a time.[3]
//为了代码的好看、可读性改造的可能
Purely functional programs can use monads to structure procedures that include sequenced operations like those found in structured programming.[4][5]
The name and concept comes from category theory, where monads are one particular kind of functor, a mapping between categories.
Monad (functional programming), functional programming constructs that capture various notions of computation
https://en.wikipedia.org/wiki/Monad
defer
defer本意:延时执行,重点考察执行的时机。
对应常见模式中的懒加载模式。
对应代理模式。
Proxy:代理提供接口使客户端能够调用主动对象,当代理被调用时,将创建一个future对象,一个方法请求,并将方法请求添加到激活队列中。