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 ...
随机推荐
- BUPT2017 springtraining(15) #3
这里这里 A.签到题 #include <cstdio> double a[] = {0.4, 0.16, 0.063, 0.025, 0.010, 0.004}; int main() ...
- Maven学习总结(3)——使用Maven构建项目
Maven学习总结(三)--使用Maven构建项目 maven作为一个高度自动化构建工具,本身提供了构建项目的功能,下面就来体验一下使用maven构建项目的过程. 一.构建Jave项目 1.1.创建J ...
- [luoguP1993] 小 K 的农场(差分约束 + spfa 判断负环)
传送门 差分约束系统..找负环用spfa就行 ——代码 #include <cstdio> #include <cstring> #include <iostream&g ...
- 20180703mysql运维专题一:利用etl监控mysql日志
参考地址: https://www.elastic.co/solutions/logging https://www.elastic.co/guide/en/beats/filebeat/curren ...
- [bzoj2060][Usaco2010 Nov]Visiting Cows 拜访奶牛_树形dp
Visiting Cows 拜访奶牛 bzoj-2060 Usaco-2010 Nov 题目大意:题目链接. 注释:略. 想法:看起来像支配集. 只是看起来像而已. 状态:dp[pos][flag]表 ...
- HPC2013小节
对于高性能计算,三个分支能耗.高性能.容错.下面我对会议的主要内容作一个小节,很多问题也是不求甚解. 下面针对大会内容,我主要总结如下,会有了解不周的地方,欢迎讨论:大会主要报告分成3个方向,1.基础 ...
- 实现MVC.NET 5的国际化
实现国际化有三种做法: 创建资源文件. 每种语言设置一套单独的View. 1 + 2. 通常而言,第一种方法的可维护性是最高的.因为随着项目的规模的扩大,为每种语言设置一套单独的View,前期的工作量 ...
- MSP430WARE++的使用2:RSP1 driver的调用方法
MSP430WARE是一套基于C++语言的开源的MSP430层次化软件架构,支持多种外设.本文将介绍雷达測速芯片RSP1驱动程序的调用方法. 1.硬件原理图 採用下图所看到的 ...
- java的list类
java的list类 目录: list中添加,获取,删除元素: list中是否包含某个元素: list中根据索引将元素数值改变(替换): list中查看(判断)元素的索引: 根据元素索引位置进行的判断 ...
- servlet中的中文乱码问题
老师总会说道:学完这个知识点,我们来谈谈中文乱码问题. 乱码的问题总是无处不在,处理不好会给用户带极差的用户体验. 那么我们来记录一下servlet中的乱码问题吧! 1.服务器向客户端响应时出现的乱码 ...