Sometimes I am confused with 'liftA2' and 'converge' functions.

Main difference between those is that:

  liftA2 takes applicative functor as second and third arguements, for example, array

  converge takes functions as second and third arguements

// liftA2 :: Applicative m => (a -> b -> c) -> m a -> m b -> m c
// converge :: (b -> c -> d) -> (a -> b) -> (a -> c) -> a -> d
// liftA2 :: Applicative m => (a -> b -> c) -> m a -> m b -> m c
// converge :: (b -> c -> d) -> (a -> b) -> (a -> c) -> a -> d
const { option, curry, liftA2, converge } = require("crocks");
const { getState } = require("../../helper"); // getColors :: () -> State AppState [String]
const getColors = () => getState("colors").map(option([])); // getShapes :: () -> State AppState [String]
const getShapes = () => getState("shapes").map(option([])); // buildCard :: String -> String -> Card
const buildCard = curry((color, shape) => ({
id: `${color}-${shape}`,
color,
shape
})); // buildCards :: [String] -> [String] -> [Card]
const buildCards = liftA2(buildCard); // generateCards :: () -> State AppState [ Card ]
const generateCards = converge(liftA2(buildCards), getColors, getShapes); module.exports = {
generateCards
};

[Functional Programming] liftA2 and converge的更多相关文章

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

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

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

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

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

  5. Functional programming

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

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

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

  7. Functional programming idiom

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

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

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

  9. Functional Programming 资料收集

    书籍: Functional Programming for Java Developers SICP(Structure and Interpretation of Computer Program ...

随机推荐

  1. 了解 DML、DDL、DCL

    一.DML DML(Data Manipulation Language)数据操纵语言: 最经常用到的 SELECT.UPDATE.INSERT.DELETE. 主要用来对数据库的数据进行一些操作 S ...

  2. LIUNX随堂学习-3 权限

    1.权限分为三类:读r,写w,执行x 2.读r:可以ls改目录下的子文件名,子目录名 写w:可以在该目录下创建.删除.重命名 执行x:可以cd到该目录下 3. ll  (ls -l) 下详细信息的意义 ...

  3. 【Scratch】它跟Mindstorms,有什么区别?

    第197篇文章 老丁的课程 在正式开始这套课程之前,依照老丁的习惯,还是要给大家白话下东西,该怎么学? 本节课,来讲讲我对于学习这个软件(包括和EV3配合起来)的一些看法.同时,也给小朋友们一些编程学 ...

  4. 阿里云ecs不同网段内网互通

    建立ClassicLink连接 官方文档:https://help.aliyun.com/document_detail/65413.html?spm=a2c4g.11186623.2.12.16c9 ...

  5. dockerfile相关命令

    官方dockerfile:https://github.com/play-with-docker/play-with-docker 可以根据一直的镜像,学习dockerfile的编写 dockerfi ...

  6. 我对DES AES RSA的认识

    1.DES(Data Encryption Standard)算法:数据加密标准.是替换和置换细致而复杂的结合体,替换和置换一个接着一个,共循环16次.算法首先将明文分块,每块64位.密钥也是64位, ...

  7. cnn健康增胖和调理好身体

    吃不胖,其实大部分情况是消化系统不好,大部分食物都没有被身体吸收就被排掉了. 1,改善肠胃消化功能: 每天早上一杯全脂鲜牛奶(或者羊奶), 每天晚上一杯酸奶 ps:白天和鲜牛奶可以激发肠胃的消化能力. ...

  8. Django rest-framework框架-组件之渲染器

    渲染器: from rest_framework.renderers import BrowsableAPIRenderer,AdminRenderer,HTMLFormRenderer,JSONRe ...

  9. Pandas进阶之提升运行效率

    前言 如果你现在正在学习数据分析,或者正在从事数据分析行业,肯定会处理一些大数据集.pandas就是这些大数据集的一个很好的处理工具.那么pandas到底是什么呢?官方文档上说: " 快速, ...

  10. vue的自定义指令

    点击元素之外触发函数 <template> <div v-clickoutside="clickItemOut"></div> </tem ...