Awesome Fp Js Overview
:sunglasses: A curated list of awesome functional programming stuff in js
🏠 Home · 🔥 Feed · 📮 Subscribe · ❤️ Sponsor · 😺 stoeffel/awesome-fp-js · ⭐ 6K · 🏷️ Programming Languages
Awesome FP JS
This is a curated list of awesome functional programming code and learning resources for JavaScript. As a multi-paradigm programming language, JavaScript can be written in many styles. With these resources we want to help you to make better use of JavaScript’s support for writing programs in a functional way.
Functional programming is a style of programming which models computations as the evaluation of expressions. Contrast this with imperative programming where programs are composed of statements which change global state when executed. Functional programming typically avoids using mutable state and favors side-effect free functions and immutable data instead. This encourages writing composable and declarative programs that are easy to reason about.
Table of Contents
- Libraries
- Functional Languages that Compile to JavaScript
- Programming Tools
- Resources
- Community
- Contribution
Tags
These may be appended to entries. Each should be preceded by a "+" or "-" to indicate presence or absence of the tag's meaning. "-" tags should only be included when they are likely to help someone filter libraries for their needs. For instance, -TS
tags are probably useful for Typescript users screening for types, but -CT
tags would be less likely to be helpful to anyone.
- CT. Category Theory. This library appears to be inspired by Haskell, Scala, or another functional language's library with a grounding in Category Theory.
- TS. Typescript. This library has typescript types.
Libraries
- Ramda (⭐24k) – A practical functional library for JavaScript that is designed specifically for a functional programming style. A style that makes it easy to create functional pipelines and never mutates user data. +TS.
- Ramda Adjunct (⭐682) is a community-maintained extension of Ramda.
- Ramda-extension (⭐167) is set of utility point-free functions composed only from Ramda functions.
- Rambda (⭐1.7k) - A faster alternative to Ramda in under 10kB.
- Rambdax (⭐221) - Extended version of Rambda
- Folktale – A standard library for functional programming in JavaScript. Typescript support expected mid-2020. -TS.
- lodash/fp (⭐60k) – An instance of Lodash (⭐60k) with its methods wrapped to produce immutable, auto-curried, iteratee-first, data-last methods. +TS.
- functional.js (⭐223) – A lightweight functional JavaScript library that facilitates currying and point-free / tacit programming.
- 101 (⭐1.6k) – A modern and modular JavaScript utility library made to work well with vanilla JavaScript methods. -TS
- fnuc (⭐16) – A functional library for CoffeeScript (and JavaScript) to facilitate functional composition and higher order functions.
- barely-functional (⭐107) – A tiny (2.7kb) functional programming library using native ES5/6 operations. -TS.
- bluebird-promisell (⭐44) - A practical functional programming library for promises.
- prelude.ls – A functionally oriented utility library somewhat based off of Haskell's Prelude module. -TS.
- preludejs (⭐100) - Hardcore Functional Programming for JavaScript. -TS.
- 1-liners (⭐793) – Functional tools that couldn’t be simpler. A dead simple functional utility belt, hand-crafted with love and attention. -TS.
- fn-curry (⭐5) – A simple function to curry a function.
- curry (⭐85) – Curry your functions using function bind syntax.
- compose-function (⭐56) – Compose a new function from smaller functions.
- functionize (⭐49) – A collection of functions which aid in making non-functional libraries functional.
- lambdajs (⭐143) – The full ECMAScript API done a functional way.
- fp-dom – Making the DOM functional.
- react-on-lambda (⭐264) - Replace JSX in React with functions (currying, compositions and etc).
- trifl (⭐36) – A functional user interface library with unidirectional dataflow and a virtual dom.
- funcy (⭐247) – An experiment in adding functional pattern matching to JavaScript. Experimental :triangular_flag_on_post:
- date-fp (⭐121) – A functional utility library for working with JavaScript dates. All functions in date-fp are pure, autocurried and will not mutate the date objects they are applied to.
- js-joda (⭐1.6k) – An immutable date and time library that provides a simple, domain-driven and clean API based on the ISO8601 calendar.
- _part_ (⭐41) – A micro library that encourages functional programming by making native methods available as partially applied functions.
- claire (⭐79) – A property-based testing library for clearly specifying code invariants and behaviour.
- FPO.js (⭐447) – FP library for JavaScript by Kyle Simpson (aka getify). Supports named-argument style methods.
- Javascript Parser Combinator (⭐145) – Javascript parser combinator implementation inspired by the Haskell's Parsec
- fun-task (⭐373) – An abstraction for managing asynchronous code in JS. Tasks are similar to Promises with the key difference that Tasks can represent a computation while Promises can represent only the results of a computation. Ships with Flow type definitions.
- most (⭐3.5k) – Ultra-high performance reactive programming to help you compose asynchronous operations on streams of values and events without many of the hazards of side effects and mutable shared state.
- zen-signals (⭐53) – ☯ The simplest signal library possible
- funfix (⭐632) – Funfix is a library of type classes and data types for Functional Programming in JavaScript, TypeScript and Flow. +CT, +TS.
- pico-lambda (⭐71) - Arrays, Strings and things the functional way. A 640b functional library based on native methods. -TS.
- pareto-js (⭐261) - An extremely small, intuitive and fast functional utility library for JavaScript -TS.
- fpEs (⭐43) - A small library provides simple usages of basic FP & pattern-matching/sumtype & MonadIO/Rx & Optional for Javascript. -TS.
- Creed – Sophisticated and functionally-minded async with advanced features: coroutines, promises, ES2015 iterables, fantasy-land. -TS.
- TGrid (⭐146) - Grid Computing Framework, Network & Thread extension of TSTL (⭐603), supporting RFC (Remote Function Call). +TS.
- Ferrum (⭐519) – Iterator library with support for objects as iterables, lazy evaulation and
pipe()
; implements Traits (from Rust)/Type Classes (from Haskell) in JS. -TS. - fp-ts - Typed functional programming in TypeScript. +CT, +TS.
- iter-tools (⭐170) - a rich toolset for working with iterables, both sync and async. +TS.
- remeda A function library roughly subsetting Ramda, but written in Typescript and thus more type-friendly. +TS.
- futil-js (⭐994) - A collection of functional utilities that could conceivably be part of a library like lodash/fp, but for some reason or other are not.
- rubico (⭐276) - 🏞 [a]synchronous functional syntax
- rocket-pipes (⭐25) - Powerful pipes, that chain Promise and ADT like Maybe or Either from popular FP libraries. +TS
- omg-curry (⭐137) - Comprehensive Curry Library with Operator Curry, Curry from functions, Decurry and Infifnite Curries.
- lfi (⭐233) - A Lazy Functional Iteration Library Supporting Sync, Async, and Concurrent Iteration.
- ts-multimethod (⭐4) - TypeScript multimethods inspired by Clojure multimethods. +TS
- ts-fp-di (⭐4) - Tiny TypeScript functional dependency injection, based on Node.js AsyncLocalStorage. +TS
- effect-ts (⭐7.7k) – A Fully-fledged functional effect system for typescript with a rich standard library. +TS
- qio (⭐74) – A type-safe, functional, performant, lawful, composable data structure that solves practical problems of effect-full code in node and browser. +TS
- Ditox.js (⭐93) - Powerful dependency injection container for building modular apps. +TS
- RxEffects (⭐36) - Reactive state and effect management with RxJS. +TS
- fxts (⭐937) - Lazy evaluation and concurrency. +TS
- ts-belt - Fast, modern, and practical utility library for FP in TypeScript. (Uses a data-first approach like remeda, but is faster than remeda, ramda, rambda, and lodash/fp.)
- fp-multik - JS/TS lightweight value-multimethod util
- true-myth (⭐1k) A library for safe, idiomatic null and error handling in TypeScript, with
Maybe
andResult
types, supporting both a functional style and a more traditional method-call style - ts-pattern (⭐12k) - The exhaustive Pattern Matching library for TypeScript, with smart type inference. Pattern Matching is a code-branching technique coming from FP languages.
- hyogwa (⭐57) - Natural 🌿 effect system that fits TypeScript; Write codes as you write plain typescript code.
- Verticalize (⭐301) - Super lightweight function that looks and behaves like a pipe operator.
- PureEval (⭐37) - A powerful JavaScript functional programming toolset, including utility functions and abstract data structures.
- context-fp (⭐2) - Microscopic functional programming context aka dependency injection. +TS
- klubok (⭐1) - Pipes with easy mocking, intended for huge amount of unit tests. +TS
Data Structures
Write performant functional code by using the right data structures for the task.
- Icepick (⭐421) Utilities for treating frozen JavaScript objects as persistent immutable collections
- Immutable.js (⭐33k) – Immutable persistent data collections.
- Immer (⭐28k) – Immer is a tiny package for immutable state based on copy-on-write mechanism. +TS.
- Mori (⭐3.4k) – ClojureScript’s persistent data structures and supporting API from the comfort of vanilla JavaScript.
- Baobab (⭐3.2k) – persistent and optionally immutable data tree with cursors.
- immutable-sequence.js (⭐16) – High performance implementation of Immutable Sequence in JavaScript, based on Finger Trees (⭐45).
- Timm – Immutability helpers with fast reads and acceptable writes.
- Lazy.js (⭐6k) – A utility library with a lazy engine under the hood that strives to do as little work as possible while being as flexible as possible.
- DerivableJS (⭐515) – Functional Reactive State for JavaScript and TypeScript. DerivableJS enables you to make elegant declarative statements about how your bits of state are related. +TS.
- imlazy (⭐103) – Library for creating and manipulating lazy iterables using the ES2015 iteration protocols.
- collectable (⭐272) – Super high-performance immutable data structures for modern JavaScript and TypeScript applications. +TS.
- List (⭐1.7k) - An extremely fast immutable list with a comprehensive functional API. Designed to seamlessly integrate with Ramda (⭐1.7k).
- prelude.ts (⭐377) - Immutable persistent collections, functional constructs such as Option and Either, and combinators. Implemented in Typescript but supports javascript too. +CT, +TS.
- TSTL (⭐603) - C++ STL (Standard Template Library) is implemented in TypeScript. STL Containers, iterators, algorithms and functors, that following functional programming rule, are provided. +TS.
Algebraic Data Types
Use the laws of math instead of always reinventing your own thing. Algebraic!
- Fantasy Land (⭐10k) – Not a library, but a specification of the Monad laws for libraries to follow.
- Static Land (⭐772) – Specification similar to Fantasy Land but based on static methods rather than instance methods.
- immutable-ext (⭐489) – FantasyLand extensions for Immutable.js (⭐33k).
- daggy (⭐701) – Library for creating tagged constructors.
- Sanctuary (⭐3k) – Sanctuary makes it possible to write safe code without null checks. +CT, +TS.
- monet.js – A library that assists functional programming by providing a rich set of Monads and other useful functions. +CT, +TS.
- union-type (⭐478) – A small JavaScript library for defining and using union types.
- freeky (⭐176) – A collection of Free monads.
- Fluture (⭐2.5k) – A Future library with included control utilities, high performance and great error messages.
- fantasy-combinators (⭐66) – Common combinators.
- fantasy-birds (⭐91) – Port of the Haskell package Data.Aviary.Birds. Everything for your combinatory needs.
- crocks (⭐1.6k) – A collection of popular Algebraic Data Types with the main goal to curate and provide not only a common interface between each type, but also all of the helper functions needed to hit the ground running. -TS.
- kudo-js (⭐23) - A small utility library with a set of Algebraic Data Types and Helper functions to help you write code in a functional programming style in Javascript
- purify (⭐1.5k) - Functional programming library for TypeScript focusing on ADTs. +CT, +TS.
- MojiScript (⭐149)- an async-first, opinionated, and functional language designed to have 100% compatibility with JavaScript engines
- Pratica (⭐468) - Small, simple, easy FP data types for pragmatic and productive developers who need to ship reliable code fast. +CT, +TS.
- Tifi - Tifi is a library for functional programming in TypeScript. It solves a problem of the existence of both
undefined
andnull
. Tifi is inspired by the OCaml/Reason utilities for the option data type. +CT, +TS. - sweet-monads (⭐346) - A collection of popular monads (such as
Either
andMaybe
) and the lazy iterator.
Lenses
- lenses (⭐214) – Composable kmett (⭐2k) style lenses.
- optics (⭐87) – Profunctor optics (Lens, Prism, iso).
- ramda-lens (⭐184) – 🐏 :mag_right: Lens library built on Ramda.
- fantasy-lenses (⭐109) – Composable, immutable getters and setters. (Profunctor lenses WIP)
- nanoscope (⭐177) – Lenses with dotty support.
- partial.lenses (⭐918) – Partial lenses is a comprehensive, high-performance optics library for JavaScript.
- shades (⭐414) – A lodash-inspired lens-like library for Javascript.
Functional Languages that Compile to JavaScript
- ClojureScript (⭐9.2k) – Compiles Clojure, a hosted Lisp with immutable persistent data structures, to JavaScript.
- Elm – A type-safe functional programming language for declaratively creating web browser-based graphical user interfaces. Implemented in Haskell.
- Fable - Compiles F# to readable JavaScript.
- PureScript – A small strongly typed programming language that compiles to JavaScript.
- Idris – A general purpose pure functional programming language with dependent types.
- GHCJS (⭐2.6k) – Haskell to JavaScript compiler, based on GHC.
- ElixirScript (⭐1.6k) – Compiles a subset of Elixir, a dynamic, functional language designed for building scalable and maintainable applications, to JavaScript.
- Js_of_ocaml – Compiles OCaml bytecode to JavaScript, making it possible to run OCaml programs in the browser.
- Reason – Reason is a new interface to OCaml, a highly expressive dialect of the ML language featuring type inference and static type checking.
- ReScript – (previously known as Bucklescript) ReScript is a type-safe language that compiles to the highest quality of clean, readable and performant JavaScript code.
- Scala.js – Compiles Scala to JavaScript.
- LiveScript – LiveScript has a straightforward mapping to JavaScript and allows you to write expressive code devoid of repetitive boilerplate.
- Quack (⭐323) - A multi-paradigm programming language with gradual and duck typing that targets PHP and JS.
- ion (⭐80) - no BS JS
- RamdaScript (⭐132) - A Lisp that compiles to opinionated JavaScript on top of RamdaJS
- RacketScript (⭐13) – RacketScript aims to leverage both JavaScript and Racket's ecosystem, and make interoperability between them clean and smooth.
- Koka – Koka is a function-oriented programming language that seperates pure values from side-effecting computations with a familiar JavaScript like syntax.
- TypeScript - TypeScript is a typed superset of JavaScript that compiles to plain JavaScript.
- Gleam - Gleam is a typed, functional language that compiles to Erlang and JavaScript.
Programming Tools
- eslint-plugin-fp (⭐967) - ESLint rules for functional programming
- 4.5 (⭐21) – A functional assertions library. If you prefer functional style APIs and practices in JavaScript, this library aims to solve this with functionally-oriented assertions that are lazy and monadic.
- hm-def (⭐198) – Runtime type checking for JS with Hindley Milner signatures.
- ftor (⭐44) - A pluggable runtime type checker and functional debugging tool that supports parametric and row polymorphism, implicit rank-2 types and algebraic data types via Scott Encoding.
Resources
Books
- Professor Frisby’s Mostly Adequate Guide to Functional Programming (⭐23k) – This is a book on the functional paradigm in general using the world’s most popular functional programming language: JavaScript. It’s a practical introduction that builds up intuition through real-world examples. Strongly recommended. By Brian Lonsdorf (2016)
- Functional-Light JavaScript (⭐17k) – This book explores the core principles of functional programming (FP) that can be applied to JavaScript. But what makes this book different is that it approaches these principles without all the heavy terminology.
- JavaScript Allongé, the “Six” edition. Starts with as little as possible about functions – but no less! – and builds up towards powerful combinators and decorators. A foundational book. By Reginald Braithwaite (2016)
- Functional Programming in JavaScript teaches JavaScript developers functional techniques that will improve extensibility, modularity, reusability, testability, and performance. Through concrete examples and jargon-free explanations, this book teaches you how to apply functional programming to real-life development tasks. By Luis Atencio (2016)
- Eloquent JavaScript. A modern introduction to programming using JavaScript. By Marijn Haverbeke (2014)
- Functional JavaScript teaches how to create code that’s beautiful, safe, and simple to understand and test by using JavaScript’s functional programming support. By Michael Fogus (2013)
- Grokking Simplicity teaches functional programming from first principles. It uses JavaScript for all code examples and it uses real-world scenarios. By Eric Normand (2019)
- scriptum (⭐384) - a no-frills functional programming library and a online course based on it
Articles
- FP Concepts in JavaScript – An introduction to Functional Programming Concepts in JavaScript. Uses the Ramda library to teach the concepts of composition, pointfree style, and functors through the simplest of examples.
- Functional programming with JavaScript – Another introduction to Functional Programming in JavaScript with a focus on three key themes: computation as the application of functions, statelessness, avoiding side effects.
- A gentle introduction to functional JavaScript – A four-part series introduction functional programming in JavaScript that gets you up to speed what all the hype about functional programming is all about.
- Functors from first principle - explained with JS - Explaining functors concept using JavaScript.
- Why Curry Helps – A short overview of how to write reusable and declarative code using currying.
- Favoring Curry - Practical applications of currying using Ramda.
- Functional Mumbo Jumbo – ADTs – A beginner-friendly introduction to Algebraic Data Types.
- JavaScript and Type Thinking – Learn to reason about your JavaScript code with type thinking. Algebraic Data Types are introduced as a conceptual basis to reason about program entities.
- Lazy, composable, and modular JavaScript – Use four new features of ES6 – iterables, generators, fat arrows, and for-of – in conjunction with higher-order functions, function composition, and lazy evaluation, to write cleaner and more modular JavaScript.
- Why Ramda – To those not used to functional programming, Ramda seems to serve no purpose whatsoever. However, it does offer a different style of coding, a style that’s taken for granted in purely functional programming languages: Ramda makes it simple for you to build complex logic through functional composition.
- Monads in JavaScript – An introduction to the Monad design pattern in JavaScript.
- A Monad in Practicality: First-Class Failures – A walk through some practical use cases for specific monadic structures in JavaScript: use the
Maybe
monad to handle simple failure cases and model more complex scenarios with theEither
monad or theValidation
applicative functor. - Functional programming – Many articles on various aspects of functional programming in JavaScript by Gleb Bahmutov.
- Functional Programming Jargon (⭐19k) – Jargon from the functional programming world explained in JavaScript.
- Data Structures in JavaScript – A series of blog posts that reimplements various data structures in JavaScript to better understand their benefits and downsides.
- So You Want to be a Functional Programmer - Easy to understand, with some examples, introduction to Functional Programming in Javascript and Elm.
- Functional Programming for JavaScript People - A complete introduction to functional programming patterns by Chet Corcos with a lot of javascript examples.
- Introduction to Immutable.js and Functional Programming Concepts - Learn about functional data structures and their uses in this overview of Facebook's popular library for JavaScript: Immutable.js.
- Master the JavaScript Interview: What is Functional Programming? - A simple introduction by @ericelliott to functional principles and vocabulary.
- Composing Software - A series of articles on learning functional programming and compositional software techniques in JavaScript ES6+ from the ground up by @ericelliott.
- Anonymous Recursion in JavaScript - Short and easy to understand article about implementing anonymous recursion in JavaScript.
- Functional Composition in Javascript – Step by step explanation of how to compose functions in javascript.
- Functional Programming Principles in Javascript - Practical code examples to learn functional programming concepts like pure function, immutability, first-class entities, and higher order functions
- Basic Monads in Javascript - Introduction to 2 easy monads in Javascript, Maybe & Either.
- F# for JavaScript Devs - Showcasing the similarities between F# and JavaScript
- A practical guide to writing more functional Javascript - A step by step guide to convert imperative JavaScript to more declarative, functional JavaScript.
- You don't (may not) need loops ➿ (⭐1.1k) - Loops are one of the first constructs that junior programmers learn, but they can pose many potential issues in the software development process, and could be avoided in many cases.
Videos
- Classroom Coding with Prof. Frisby – A series that builds a “practical” web application with React and functional programming in JavaScript.
- Hey Underscore, You're Doing It Wrong! – Underscore.js claims to be a functional programming library, but is it really?
- Functional programming patterns for the non-mathematician – Learn about practical use cases for functors, applicatives, and monads.
- Pure JavaScript – Christian Johansen will show you how you can significantly up your game by leaving loops behind and embracing functions as the primary unit of abstraction.
- Functional programming in JavaScript - A series by Mattias Petter Johansson, from the youtube channel FunFunFunction, that is specifically about popularization of functional programming in JavaScript.
- Functional Programming in TypeScript - Discover functional programming with Typescript and create a library like fp-ts alongside Sahand Javid in this beginner-friendly YouTube playlist.
- Anjana Vakil: Learning Functional Programming with JavaScript - JSUnconf 2016 - A simple and understandable introduction of functional proramming in javascript.
- Functional Programming Basics In ES6 - A complete introduction to functional programming in javascript made it easy by ES6.
- JavaScript Programmers Should Learn Algebraic Data Types -- May 2018 -- UtahJS Lehi - Seth House explains how ADTs (Algebraic Data Types) can be useful to JavaScript developers.
Examples and Exercises
- FPJS-Class (⭐93) – Functional Programming learned through JavaScript.
- functional-javascript-workshop (⭐2.1k) – The goal of this workshop is to create realistic problems that can be solved using terse, vanilla, idiomatic JavaScript to teach fundamental functional programming features of JavaScript.
- functional-frontend-architecture (⭐1.4k) – A functional frontend framework. Based on Ramda + union-type-js + Flyd + Snabbdom
- cube-composer (⭐2k) – A puzzle game inspired by functional programming.
- FP Youtube Search (⭐57) – YouTube search app with ReactJS, Redux, and FP concepts
- Hardcore Functional Programming in JavaScript – Learn to apply techniques from the forefront of computer science research to solve practical problems in Javascript. Discover functional programming and see it demonstrated step-by-step with how to build an example web app using abstract interfaces like Monads, Functors, Monoids and Applicatives. (commercial)
- Escape from Callback Mountain (⭐258) - Design & refactoring tips for Promise-based Functional JavaScript. Key benefits include better readability, testability, and reusability. MIT.
- Learn Rx – A series of interactive exercises introducing five basic ingredients of functional (reactive) programming: the
map
,filter
,concatAll
,reduce
, andzip
functions. - Holdem Evaluator - Yet another Holdem Evaluator with Ramda functional style
Community
Related Lists
- Awesome FRP JS (⭐284) – A curated list of awesome (functional) reactive programming stuff in JavaScript.
- lucasviola/Awesome Functional Programming (⭐963) – Awesome resources on functional programming theory and learning materials.
- xgrommx/Awesome Functional Programming (⭐3.5k) – A ton of articles on functional programming, as well as a huge list of functional libraries for many programming languages.
- Functional Programming Resources In JavaScript (⭐305)
- tk-learning-center/Functional Programming Learning Path (⭐990) - A Learning Path for Functional Programming
Talk
- Functional Programming Slack channel – Community with a friendly channel for JavaScript as well as many other channels about functional programming in general.
Contribution
⭐ Suggestions and PRs are welcome! ⭐
Please read the contribution guidelines to get started.
License
To the extent possible under law, Christoph Hermann has waived all copyright and related or neighboring rights to this work.