Monad (functional programming)
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. For example, the simple Maybe monad encapsulates variables which may have a null value, representing an option type, and automatically ensures that null values are not passed as arguments to functions that cannot handle them, serving as an alternative programming technique to throwing and catching exceptions when null values arise. Another example is the List monad, where the empty list is a constant value of type List, and the cons operator binds a plain value as the head of a previous list.
The monad represents computations with a sequential structure: a monad defines what it means to chain operations together. This enables the programmer to build pipelines that process data in a series of steps (i.e. a series of actions applied to the data), in which each action is decorated with the additional processing rules provided by the monad.[2] A monad is defined by a return operator that creates values, and a bind operator used to link the actions in the pipeline; this definition must follow a set of axioms called monad laws, which are needed for the composition of actions in the pipeline to work properly.
https://en.wikipedia.org/wiki/Monad_(functional_programming)
Monad (functional programming)的更多相关文章
- Functional Programming without Lambda - Part 2 Lifting, Functor, Monad
Lifting Now, let's review map from another perspective. map :: (T -> R) -> [T] -> [R] accep ...
- Beginning Scala study note(4) Functional Programming in Scala
1. Functional programming treats computation as the evaluation of mathematical and avoids state and ...
- Functional Programming without Lambda - Part 1 Functional Composition
Functions in Java Prior to the introduction of Lambda Expressions feature in version 8, Java had lon ...
- a primary example for Functional programming in javascript
background In pursuit of a real-world application, let’s say we need an e-commerce web applicationfo ...
- Functional programming
In computer science, functional programming is a programming paradigm, a style of building the struc ...
- Java 中的函数式编程(Functional Programming):Lambda 初识
Java 8 发布带来的一个主要特性就是对函数式编程的支持. 而 Lambda 表达式就是一个新的并且很重要的一个概念. 它提供了一个简单并且很简洁的编码方式. 首先从几个简单的 Lambda 表达式 ...
- Functional programming idiom
A functional programming function is like a mathematical function, which produces an output that typ ...
- 关于函数式编程(Functional Programming)
初学函数式编程,相信很多程序员兄弟们对于这个名字熟悉又陌生.函数,对于程序员来说并不陌生,编程对于程序员来说也并不陌生,但是函数式编程语言(Functional Programming languag ...
- Functional Programming 资料收集
书籍: Functional Programming for Java Developers SICP(Structure and Interpretation of Computer Program ...
随机推荐
- linux -- 视频尺寸-cif、2cif、dcif、D1、HD1、4D1
1 CIF简介 CIF是常用的标准化图像格式(Common Intermediate Format).在H.323协议簇中,规定了视频采集设备的标准采集分辨率.CIF = 352×288像素 ...
- 利用DTrace实时检测MySQl
与我们大多数人想象的不同,DTrace用于MySQL时不需对MySQL做任何更改.DTrace最强大的“提供器”(provider,是一组可观测的探测器)是FBT(Functional Boundar ...
- oracle capability i/o(压力測试数据库serveri/o性能)
今天是2014-04-21,今天简单仅仅说明一下怎么影响重做数据的一个因素,那就是i/o吞吐量,oracle的介质恢复依赖于i/o,假设i/o存在瓶颈,那么势必会影响备库的介质恢复. 那么i/o st ...
- Lightoj 1235 - Coin Change (IV) 【二分】
题目链接:http://www.lightoj.com/volume_showproblem.php?problem=1235 题意: 有N个硬币(N<=18).问是否能在每一个硬币使用不超过两 ...
- 【POJ 1201】 Intervals(差分约束系统)
[POJ 1201] Intervals(差分约束系统) 11 1716的升级版 把原本固定的边权改为不固定. Intervals Time Limit: 2000MS Memory Limit: ...
- IE6、IE7的兼容问题
通常,网页的兼容问题,就是IE6\IE7的问题.表现为错位.换行,不支持CSS3等. 而其中,错位.换行,原因往往在于没有指明元素的width.height. 一般银瓦不告诉他.
- 利用jquery将页面中所有目标为“#‘的链接改为其他URL
有一张页面草稿,开始时为了方便,里面差不多所有的<a>都指向了"#".现在要修改为另一个地址,难道要全部修改吗?用jquery 改改就好.代码如下: <scrip ...
- XML案例(简单的考生成绩管理系统)
1.以如下格式的exam.xml文件为例 <?xml version="1.0" encoding="UTF-8" standalone="no ...
- 【BZOJ2693】jzptab & 【BZOJ2154】Crash的数字表格
题目 弱化版题目的传送门([BZOJ2154]Crash的数字表格) 加强版题目的传送门([BZOJ2693]jzptab) 思路&解法 题目是要求: \(\sum\limits_{i = 1 ...
- Python 39 数据库
一:数据存储引擎 1. 什么是引擎? 一个功能的核心部分 引擎可以被分类 例如: 自然 增压 汽油 柴油 混合动力 天然气 核动力 汽油:动力弱,噪音小,震动小 柴油:动力强,污染大,噪音大,震动大 ...