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
- Programming Tools
- Folktale – Folktale is a suite of libraries for generic functional programming that allows you to write elegant modular applications with fewer bugs and more reuse.
- lodash/fp – An instance of Lodash with its methods wrapped to produce immutable, auto-curried, iteratee-first, data-last methods.
- barely-functional – A tiny (2.7kb) functional programming library using native ES5/6 operations.
- bluebird-promisell - A practical functional programming library for promises.
- prelude.ls – A functionally oriented utility library somewhat based off of Haskell's Prelude module.
- 1-liners – Functional tools that couldn’t be simpler. A dead simple functional utility belt, hand-crafted with love and attention.
- 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.
- 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.
Write performant functional code by using the right data structures for the task.
- Immutable.js – Immutable persistent data collections.
- 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.
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.
- ramda-fantasy – Fantasy-Land compatible types for easy integration with Ramda.js.
- monet.js – A library that assists functional programming by providing a rich set of Monads and other useful functions.
- 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.
- 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.
- partial.lenses – Ramda compatible partial lenses. View, insert and update optional data.
- 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.
- eslint-plugin-fp - ESLint rules for functional programming
- eslint-config-cleanjs - An eslint config which reduces JS to a pure functional language
- 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
- 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.
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
- 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.
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.