Awesome FP JS ¶
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.
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.
- Ramda Adjunct is a community-maintained extension of Ramda.
- Ramda-extension is set of utility point-free functions composed only from Ramda functions.
- Rambda - A faster alternative to Ramda in under 10kB.
- Rambdax - Extended version of Rambda
- lodash/fp – An instance of Lodash with its methods wrapped to produce immutable, auto-curried, iteratee-first, data-last methods. +TS.
- barely-functional – A tiny (2.7kb) functional programming library using native ES⅚ operations. -TS.
- bluebird-promisell - A practical functional programming library for promises.
- prelude.ls – A functionally oriented utility library somewhat based off of Haskell's Prelude module. -TS.
- 1-liners – Functional tools that couldn’t be simpler. A dead simple functional utility belt, hand-crafted with love and attention. -TS.
- fn-curry – A simple function to curry a function.
- curry – Curry your functions using function bind syntax.
- compose-function – Compose a new function from smaller functions.
- functionize – A collection of functions which aid in making non-functional libraries functional.
- lambdajs – The full ECMAScript API done a functional way.
- fp-dom – Making the DOM functional.
- react-on-lambda - Replace JSX in React with functions (currying, compositions and etc).
- trifl – A functional user interface library with unidirectional dataflow and a virtual dom.
- js-joda – An immutable date and time library that provides a simple, domain-driven and clean API based on the ISO8601 calendar.
- _part_ – A micro library that encourages functional programming by making native methods available as partially applied functions.
- claire – A property-based testing library for clearly specifying code invariants and behaviour.
- fun-task – 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 – 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 – ☯ The simplest signal library possible
- pico-lambda - Arrays, Strings and things the functional way. A 640b functional library based on native methods. -TS.
- Creed – Sophisticated and functionally-minded async with advanced features: coroutines, promises, ES2015 iterables, fantasy-land. -TS.
- TGrid - Grid Computing Framework, Network & Thread extension of TSTL, supporting RFC (Remote Function Call). +TS.
- Ferrum – 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 - 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 - 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 - 🏞 [a]synchronous functional syntax
- rocket-pipes - Powerful pipes, that chain Promise and ADT like Maybe or Either from popular FP libraries. +TS
- omg-curry - Comprehensive Curry Library with Operator Curry, Curry from functions, Decurry and Infifnite Curries.
- lfi - A Lazy Functional Iteration Library Supporting Sync, Async, and Concurrent Iteration.
- ts-multimethod - TypeScript multimethods inspired by Clojure multimethods. +TS
- ts-fp-di - Tiny TypeScript functional dependency injection, based on Node.js AsyncLocalStorage. +TS
- effect-ts – A Fully-fledged functional effect system for typescript with a rich standard library. +TS
- qio – A type-safe, functional, performant, lawful, composable data structure that solves practical problems of effect-full code in node and browser. +TS
- Ditox.js - Powerful dependency injection container for building modular apps. +TS
- RxEffects - Reactive state and effect management with RxJS. +TS
- fxts - 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 A library for safe, idiomatic null and error handling in TypeScript, with
Resulttypes, supporting both a functional style and a more traditional method-call style
- ts-pattern - The exhaustive Pattern Matching library for TypeScript, with smart type inference. Pattern Matching is a code-branching technique coming from FP languages.
- hyogwa - Natural 🌿 effect system that fits TypeScript; Write codes as you write plain typescript code.
Write performant functional code by using the right data structures for the task.
- Immutable.js – Immutable persistent data collections.
- Immer – Immer is a tiny package for immutable state based on copy-on-write mechanism. +TS.
- Baobab – persistent and optionally immutable data tree with cursors.
- Timm – Immutability helpers with fast reads and acceptable writes.
- Lazy.js – 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.
- imlazy – Library for creating and manipulating lazy iterables using the ES2015 iteration protocols.
- List - An extremely fast immutable list with a comprehensive functional API. Designed to seamlessly integrate with Ramda.
- TSTL - 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 – Not a library, but a specification of the Monad laws for libraries to follow.
- Static Land – Specification similar to Fantasy Land but based on static methods rather than instance methods.
- immutable-ext – FantasyLand extensions for Immutable.js.
- daggy – Library for creating tagged constructors.
- Sanctuary – 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.
- freeky – A collection of Free monads.
- Fluture – A Future library with included control utilities, high performance and great error messages.
- fantasy-combinators – Common combinators.
- fantasy-birds – Port of the Haskell package Data.Aviary.Birds. Everything for your combinatory needs.
- crocks – 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.
- purify - Functional programming library for TypeScript focusing on ADTs. +CT, +TS.
- Pratica - 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
null. Tifi is inspired by the OCaml/Reason utilities for the option data type. +CT, +TS.
- sweet-monads - A collection of popular monads (such as
Maybe) and the lazy iterator.
- lenses – Composable kmett style lenses.
- optics – Profunctor optics (Lens, Prism, iso).
- ramda-lens – Lens library built on Ramda.
- fantasy-lenses – Composable, immutable getters and setters. (Profunctor lenses WIP)
- nanoscope – Lenses with dotty support.
- Elm – A type-safe functional programming language for declaratively creating web browser-based graphical user interfaces. Implemented in Haskell.
- Idris – A general purpose pure functional programming language with dependent types.
- Reason – Reason is a new interface to OCaml, a highly expressive dialect of the ML language featuring type inference and static type checking.
- Quack - A multi-paradigm programming language with gradual and duck typing that targets PHP and JS.
- ion - no BS JS
- eslint-plugin-fp - ESLint rules for functional programming
- hm-def – Runtime type checking for JS with Hindley Milner signatures.
- ftor - 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.
- scriptum - a no-frills functional programming library and a online course based on it
- 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.
- 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.
Maybemonad to handle simple failure cases and model more complex scenarios with the
Eithermonad or the
- You don't (may not) need loops ➿ - 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.
- 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.
- 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.
Examples and Exercises¶
- functional-frontend-architecture – A functional frontend framework. Based on Ramda + union-type-js + Flyd + Snabbdom
- cube-composer – A puzzle game inspired by functional programming.
- FP Youtube Search – YouTube search app with ReactJS, Redux, and FP concepts
- Learn Rx – A series of interactive exercises introducing five basic ingredients of functional (reactive) programming: the
- Holdem Evaluator - Yet another Holdem Evaluator with Ramda functional style
- lucasviola/Awesome Functional Programming – Awesome resources on functional programming theory and learning materials.
- xgrommx/Awesome Functional Programming – A ton of articles on functional programming, as well as a huge list of functional libraries for many programming languages.
- tk-learning-center/Functional Programming Learning Path - A Learning Path for Functional Programming
Suggestions and PRs are welcome!
Please read the contribution guidelines to get started.
To the extent possible under law, Christoph Hermann has waived all copyright and related or neighboring rights to this work.