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. 洛谷P2243 电路维修 [最短路]

    题目传送门 电路维修 题目背景 Elf 是来自Gliese 星球的少女,由于偶然的原因漂流到了地球上.在她无依无靠的时候,善良的运输队员Mark 和James 收留了她.Elf 很感谢Mark和Jam ...

  2. Python并发编程-进程的几个方法

    join()方法 from multiprocessing import Process import time def func(arg1,arg2): print('*'*arg1) time.s ...

  3. Windows 消息循环(1) - 概览

    本文从消息循环是如何驱动程序的这个角度,对 Windows 消息循环进行概览性介绍. 使用 EN5 课件获得更好的阅读体验: [希沃白板5]课件分享 : <Windows培训 - 消息循环> ...

  4. 更改paramiko 源码 记录命令实现堡垒机功能

    利用paramiko 下的demo可以很容易的实现记录客户在操作客户机时的命令,修改\demos\interactive.py def posix_shell(chan): import select ...

  5. FastReport.Net使用:[36]"续表"

    1. RepeatedBand的打印和子报表的使用. RepeatedBand实现方法:设置Band为每页重复.注意,从第二次打印开始,就是重复打印了.第一次打印不认为是RepeatedBand. 报 ...

  6. CSS 笔记——列表表格

    6. 列表表格 -> 列表 (1)list-style 基本语法 list-style : list-style-image || list-style-position || list-sty ...

  7. [NC13B]贝伦卡斯泰露/[51Nod1400]序列分解

    [NC13B]贝伦卡斯泰露/[51Nod1400]序列分解 题目大意: 给定\(A_{1\sim n}(n\le40)\),问是否能将\(A\)分解成两个相同的子序列? 思路: 折半搜索.时间复杂度\ ...

  8. 什么是ClassLoader

    ClassLoader 做什么的? 顾名思义,它是用来加载 Class 的.它负责将 Class 的字节码形式转换成内存形式的 Class 对象.字节码可以来自于磁盘文件 *.class,也可以是 j ...

  9. python爬虫我是斗图之王

    python爬虫我是斗图之王 本文会以斗图啦网站为例,爬取所有表情包. 阅读之前需要对线程池.连接池.正则表达式稍作了解. 分析网站 页面url分析 打开斗图啦网站,简单翻阅之后发现最新表情每页包含的 ...

  10. Markdown---锚点使用

    Markdown目前还没有支持文内锚点的标记语法:但是支持html,所以锚点可以通过html语法来实现 使用方法 <a href='#jump'>第一个题目</a> 带有锚点的 ...