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 ...
随机推荐
- iOS:去除UITableView的空白行
要去除UITableView在运行时显示的多余空白行,只需要将TableView的Style从Plain改为Grouped即可.
- 豆瓣 jsonp 请求数据 并分页
豆瓣分页 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4 ...
- NJUPT JAVA语言 流处理程序设计
一. 实验目的和要求 实验目的和要求:要求学生能在学习和理解课堂学习内容中JAVA流编程理论的基础上,学习并逐步掌握JAVA流程序的编写和调试,学习依据处理需求对不同流的正确选择使用和组合用法. 实验 ...
- 【Ubuntu QQ】记如何在Ubuntu上安装QQ(附下载)
什么困扰着一批批的ubuntu桌面用户?是麻花藤.哦不,是QQ,怎么在ubuntu上安装完美无瑕的QQ. 最佳解决方案在“三”部分,当然前两个也不失为解决方案 一.尝试的开始 配置: 双系统:Wind ...
- Linux Framebuffer驱动框架之二软件架构(未完待续)【转】
本文转载自:http://blog.csdn.net/gqb_driver/article/details/12918547 /************************************ ...
- hdoj--5630--Rikka with Chess(规律题)
Rikka with Chess Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Othe ...
- Spring Boot 特性 —— SpringApplication
转自:https://blog.csdn.net/cqdz_dj/article/details/52910317
- Building a Space Station(bfs)
http://poj.org/problem?id=2031 题意:给出n个球的圆心坐标x,y,z, 半径r,若任意两球不相交,则在两球间建桥.问需建桥的最短距离是多少. 思路:建图,以两球间相差的距 ...
- Echarts配置
直接引入echarts 安装echarts项目依赖 cnpm install echarts --save //或者 cnpm i echarts -S 全局引入 我们安装完成之后,可以在 mai ...
- MSSQL:查看作业情况
select j.name 'Job名', j.description '描述', j.ENABLED job_enabled, cast(js.last_r ...