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 ...
随机推荐
- 如何在Tomcat (6/7/8.0) 安装SSL证书
第一步:进入Tomcat安装目录,把证书的jks格式文件放在tomcat安装目录的conf目录下即可. conf/ssl/371cloud.cn.jks 第二步: 打开tomcat配置文件 conf/ ...
- [bzoj1704][Usaco2007 Mar]Face The Right Way 自动转身机_贪心
Face The Right Way 自动转身机 bzoj-1704 Usaco-2007 Mar 题目大意:不想描述题意系列++... ...题目链接 注释:略. 想法:我们直接枚举k,然后从左往右 ...
- [转]十五天精通WCF——第十天 学会用SvcConfigEditor来简化配置
我们在玩wcf项目的时候,都是自己手工编写system.serviceModel下面的配置,虽然在webconfig中做wcf的服务配置的时候,vs提供大多 数的代码提示,但对于不太熟悉服务配置的小鸟 ...
- Adobe photoshop CC 2018安装激活教程
2017年10月,Adobe公司发布最新版Adobe CC 2018系列软件,photoshop cc 2018更是迎来惊艳的新功能.下面来分享安装和激活教程. 不会安装请加QQ:1833920353 ...
- Bag标签之删除书包中的一条数据
删除书包中的一条数据 查询 <esql module=help id=list> Select ID,Subject,Writer,DayTime From Messages </e ...
- hdu5119 Happy Matt Friends(dp)
题目链接:点击打开链接 题目描写叙述:给出n个数.求从这n个数中随意取出一些数(至少取一个)相互异或之后大于m的方案数? 解题思路:分析因为n<=40&&m<=10^6,因 ...
- JArray获取元素值
MXS&Vincene ─╄OvЁ &0000003 ─╄OvЁ MXS&Vincene MXS&Vincene ─╄OvЁ:今天很残酷,明天更残酷,后天很美好 ...
- Pycharm之Terminal使用
相当于doc命令,即工程所在目录shift+右键命令窗口打开的doc 1.清屏 ------ cls 清除屏幕上的所有显示,光标置于屏幕左上角.
- AFNetworking 3.0携带參数上传文件Demo
一.服务端代码: 服务端是java用国产nutz搞的,实际mvc框架都大同小异.就是提交文件的同一时候还带了个表单參数 @AdaptBy(type=UploadAdaptor.class, args= ...
- luogu1268 树的重量
题目大意 给出一棵树上每两个叶子节点之间的距离,求树的总边权和. 题解 定义节点a到b的简单路径长度为[a,b],树中节点c要到达路径[a,b]所要经过的距离为dist(c, [a,b]),在树中,与 ...