[Functional Programming] Function signature
It is really important to understand function signature in functional programming.
The the code example below:
const map = fn => anyFunctor => anyFunctor.map(fn);
'map' is pointfree version of any founctor's map, for example:
Maybe.of('maybe').map(toUpper)
equals:
compose(map(toUpper), Maybe.of)('maybe') // Just 'MAYBE'
So what is the function signature for 'map'?
fn: is a function, we can use
(a -> b) : We read it as "A function which take a to b"
anyFunctor: is a Functor, any Functor, we can use:
f a: here 'f' means Functor, 'a' means 'any value': We read it as 'Any functor a'
anyFunctor.map(fn): is what the return value, it is also a Functor, value may different from 'a':
f b: here 'f' means Functor, 'b' means 'any value but not the same as 'a' '.
Here we want to point out 'f' is Functor, we can do: 'Functor f =>'
// map :: Functor f => (a -> b) -> f a -> f b
This is the whole result:
// map :: Functor f => (a -> b) -> f a -> f b
const map = fn => anyFunctor => anyFunctor.map(fn);
[Functional Programming] Function signature的更多相关文章
- Functional programming idiom
A functional programming function is like a mathematical function, which produces an output that typ ...
- 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 ...
- Functional Programming without Lambda - Part 2 Lifting, Functor, Monad
Lifting Now, let's review map from another perspective. map :: (T -> R) -> [T] -> [R] accep ...
- 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)
初学函数式编程,相信很多程序员兄弟们对于这个名字熟悉又陌生.函数,对于程序员来说并不陌生,编程对于程序员来说也并不陌生,但是函数式编程语言(Functional Programming languag ...
- BETTER SUPPORT FOR FUNCTIONAL PROGRAMMING IN ANGULAR 2
In this blog post I will talk about the changes coming in Angular 2 that will improve its support fo ...
随机推荐
- linux-ARM的几个使用指令
1.u-boot.bin arm-linux-gnueabi-objdump -D -b binary -m arm u-boot.bin > u-boot.s arm-linux-gnueab ...
- JAVA中常见异常小结
1.java.lang.ArithmeticException 算术运算异常,例如除数为0,所以引发了算数异常 2.Java.lang.StringIndexOutOfBoundsException: ...
- AOP的自动代理
Spring的aop机制提供两类方式实现类代理.一种是单个代理,一种是自动代理. 单个代理通过ProxyFactoryBean来实现(就如上面的配置). 自动代理:自动代理能够让切面定义来决定那个be ...
- Hibernate 悲观锁(Pessimistic Locking)
在日常开发中并发应该是比较常遇到的业务场景,Hibernate给我们提供了并发操作,接下来简单介绍一下Hibernate悲观控制. 悲观锁:用户其实并不需要花很多精力去担心锁定策略的问题,通常情况下, ...
- bzoj 2038 小z的袜子 莫队例题
莫队,利用可以快速地通过一个问题的答案得到另一问题的答案这一特性,合理地组织问题的求解顺序,将已解决的问题帮助解决当前问题,来优化时间复杂度. 典型用法:处理静态(无修改)离线区间查询问题. 线段树也 ...
- Codeforces Beta Round #7 B. Memory Manager 模拟题
B. Memory Manager 题目连接: http://www.codeforces.com/contest/7/problem/B Description There is little ti ...
- Codeforces Round #300 D. Weird Chess 水题
D. Weird Chess Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/538/proble ...
- CentOS下使用KVM克隆虚拟机自动修改网卡的MAC地址
克隆完虚拟机之后Mac地址还保留着母机的配置,此时需要修改成新的Mac地址才能继续,网上一般都是这样的手动操作: 参考:http://blog.51cto.com/freedyong/1361907 ...
- Highcharts构建分组分类坐标轴
Highcharts构建分组分类坐标轴 分组分类坐标轴是将坐标轴的类别标签进行进一步分组,从而形成双层.多层结构. 这样更利于数据分组展现. 实现分组分类坐标轴须要借助第三方插件Grouped-Cat ...
- Fiddler2 抓取手机APP数据包
原文:http://blog.goyiyo.com/archives/2044 下载安装运行后,查出运行机器的IP,手机连接同一网域内的WIFI,手机WIFI连接设置里的高级里,代理设置填写上Fidd ...