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的更多相关文章

  1. Functional programming idiom

    A functional programming function is like a mathematical function, which produces an output that typ ...

  2. Beginning Scala study note(4) Functional Programming in Scala

    1. Functional programming treats computation as the evaluation of mathematical and avoids state and ...

  3. 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 ...

  4. Functional Programming without Lambda - Part 2 Lifting, Functor, Monad

    Lifting Now, let's review map from another perspective. map :: (T -> R) -> [T] -> [R] accep ...

  5. 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 ...

  6. Functional programming

    In computer science, functional programming is a programming paradigm, a style of building the struc ...

  7. Java 中的函数式编程(Functional Programming):Lambda 初识

    Java 8 发布带来的一个主要特性就是对函数式编程的支持. 而 Lambda 表达式就是一个新的并且很重要的一个概念. 它提供了一个简单并且很简洁的编码方式. 首先从几个简单的 Lambda 表达式 ...

  8. 关于函数式编程(Functional Programming)

    初学函数式编程,相信很多程序员兄弟们对于这个名字熟悉又陌生.函数,对于程序员来说并不陌生,编程对于程序员来说也并不陌生,但是函数式编程语言(Functional Programming languag ...

  9. 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 ...

随机推荐

  1. Vijos1448 校门外的树 [树状数组]

    题目传送门 校门外的树 描述 校门外有很多树,有苹果树,香蕉树,有会扔石头的,有可以吃掉补充体力的……如今学校决定在某个时刻在某一段种上一种树,保证任一时刻不会出现两段相同种类的树,现有两个操作:K= ...

  2. java变量的命名使用规则

    1.环境变量通常是指在操作系统中,用来指定操作系统运行时需要的一些参数 2.变量名以字母.下划线或者美元符(4上面的¥)开头,不能以数字开头,后面跟字母.下划线.美元符.数字,变量名对大小写敏感,无长 ...

  3. ref和out的用法和区别。

    关于ref和out的用法和区别在网上已经有很多的解释,这里只不过是写下对于我而说比较容易理解的解释. ref和out都可以用来在函数中返回数据,类似于c++中指针. 参数 Ref Out 是否一定需要 ...

  4. java抽象类、多态、接口

    抽象类 抽象类的产生 当编写一个类时,我们往往会为该类定义一些方法,这些方法是用来描述该类的功能具体实现方式,那么这些方法都有具体的方法体. 但是有的时候,某个父类只是知道子类应该包含怎么样的方法,但 ...

  5. 在IIS上运行node

    目录 前言 iisnode web.config 前言 之前自己搞了个域名,然后发现域名默认映射到80端口,腾讯云又没有修改映射端口的功能.然后服务器又是和几个sx一起租的,于是只能想办法把发到80端 ...

  6. 【LeetCode】32. Longest Valid Parentheses

    Given a string containing just the characters '(' and ')', find the length of the longest valid (wel ...

  7. django验证码配置与使用

    1.安装django-simple-captcha pip install django-simple-captcha 2.配置settings.py ##加app列表INSTALLED_APPS = ...

  8. 【BZOJ 3043】 3043: IncDec Sequence (差分)

    3043: IncDec Sequence Time Limit: 10 Sec  Memory Limit: 128 MBSubmit: 589  Solved: 332 Description 给 ...

  9. 矩阵&行列式

    # 代数 排列 对换,对于一个排列操作,对于一个偶排列一次对换之后变为奇排列 反之变为偶排列 行列式 N阶行列式室友N^2个数aij(i,j = 1,2,3,...n) 行列式的数=\(\sum_ { ...

  10. 关于dp骗分

    1.样例2.搜索3.大小->贪心:<1>每次选代价最小的两个矩阵                      <2> 每次选最大....                   ...