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:

  1. Define a data type, and how values of that data type are combined.
  2. 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对象,一个方法请求,并将方法请求添加到激活队列中。

转载于:https://www.cnblogs.com/feng9exe/p/8633235.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值