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. JAVAEE学习——hibernate01:简介、搭建、配置文件详解、API详解和CRM练习:保存客户

    今日学习:hibernate是什么 一.hibernate是什么 框架是什么: 1.框架是用来提高开发效率的 2.封装了好了一些功能.我们需要使用这些功能时,调用即可.不需要再手动实现. 3.所以框架 ...

  2. Dictionary<TKey,TValue>

    /* * 先将 key 和 bucket 的长度一起,经过简单的 hash 算法计算出元素应该放在哪个 bucket . * 但是,元素并不是放在 bucket 里面的,bucket 只是对元素存放位 ...

  3. OpenVAS漏洞扫描基础教程之创建用户组与创建角色

    OpenVAS漏洞扫描基础教程之创建用户组与创建角色 OpenVAS创建用户组 用户组就是指许多个用户的组合.在网络中,各个访问网络的用户的权限可能各不相同.所以,可以通过将具体相同权限的用户划为一组 ...

  4. intellij idea 中文 汉化包 韩梦飞沙

    韩梦飞沙  韩亚飞  313134555@qq.com  yue31313  han_meng_fei_sha 汉化包 百度云盘 下载地址: https://pan.baidu.com/s/1hs6B ...

  5. Tsinsen 最长双回文串

    求最长双回文串,正反建回文树求最大. 题目链接:http://www.tsinsen.com/ViewGProblem.page?gpid=A1280 By:大奕哥 #include<bits/ ...

  6. 【欧拉定理】BZOJ3884-上帝与集合的正确用法

    [题目大意] 求2^(2^(2^(2^(2^...)))) mod p. [思路] 蒟蒻在知道用欧拉做的前提下,对这题目瞪了好久没有明白,看了正解扑通一声跪下来orz直接搬运popoqqq大爷的吧反正 ...

  7. noip2011初赛提高组 试题详解

    转载自:https://blog.csdn.net/Eirlys_North/article/details/52889993 一.单项选择题(共20题,每题1.5分,共计30分,每题有且仅有一个正确 ...

  8. python函数 divmod

    divmod(a,b)函数 中文说明: divmod(a,b)方法返回的是a//b(除法取整)以及a对b的余数 返回结果类型为tuple 参数: a,b可以为数字(包括复数) from 2. Add ...

  9. Struts+Hibernate+Spring常见问题

    http://wanglihu.iteye.com/blog/1897718 1.java.lang.NoClassDefFoundError: org/objectweb/asm/ClassVisi ...

  10. Git配置非22端口,解决:ssh: connect to host xxx port 22: Connection timed out fatal: The remote end hung up unexpectedly

    背景:私自搭建了Git服务器,而Git本身就是SSH进行连接的,而Git命令上默认只能通过22端口实现. 解决方法: 第一种: 在系统的用户目录下的文件夹:.ssh 如果该路径下没有config文件, ...