Книга: Functional Programming in JavaScript
Назад: Function compositions, revisited
Дальше: Maybes

Monads

Monads are tools that help you compose functions.

Like primitive types, monads are structures that can be used as the containers that functors "reach into". The functors grab the data, do something to it, put it into a new monad, and return it.

There are three monads we'll focus on:

  • Maybes
  • Promises
  • Lenses

So in addition to arrays (map) and functions (compose), we'll have five functors (map, compose, maybe, promise and lens). These are just some of the many other functors and monads that are out there.

Назад: Function compositions, revisited
Дальше: Maybes

bsn
thank
Vesa Karvonen
I hope you don't mind, but I’d like to point you and your readers to my high-performance optics library for JavaScript that is in production use in multiple projects, has comprehensive support for partial optics and interactive documentation: https://calmm-js.github.io/partial.lenses/ (this takes a moment to load — be patient!)