Monad
A monad is a programming abstraction that provides operations for sequencing computations while encapsulating and preserving their computational context.
Functional Programming in Scala, Second Edition
A monad is an abstraction that represents effectful or context-dependent values and provides operations, including flatMap, for sequencing computations while preserving that context.
- How it is used
- Factors repeated sequencing logic across contextual computation types into one reusable interface.
- How deep it goes
- Defines minimal primitives and laws, derives combinators, and works through State, Option, Parser, and IO applications.
- Examples
- Uses duplicate `map2` implementations, generated orders, dependent map lookups, dynamic CSV parsing, state indexing, and console I/O.
- What you can do after
- Build it from scratch by defining `unit` and `flatMap`, deriving combinators, and checking associativity and identity laws.
Read how Functional Programming in Scala, Second Edition explains monad →
The Joy of JavaScript
An abstraction for sequencing computations through a context that can carry values and effects while supporting composition via flatMap-like chaining.
- How it is used
- Sequences container-returning functions while letting Validation stop later checks after a failure.
- How deep it goes
- Defines the map and flatMap contracts, demonstrates three laws, and builds chaining and composeM; defers extensive algebraic theory.
- Examples
- Works through Id and array chains, block-validation checks, blockchain traversal, and Promise.then flattening.
- What you can do after
- Build it from scratch with JavaScript mixins and composeM to chain Validation-returning checks.
Functional Programming in JavaScript
An abstraction that represents computations with context and provides a way to sequence them while controlling how values and effects propagate.
- How it is used
- Orchestrates safe data flow through functional pipelines handling missing values, failures, and delayed effects.
- How deep it goes
- Explains Wrapper, Maybe, Either, and IO implementations, then demonstrates map, join, chain, composition, and execution without category theory.
- Examples
- Uses student lookup and address access, even-number halving, URI decoding, DOM updates, and a student-information display pipeline.
- What you can do after
- Apply it via JavaScript container types to compose validation, lookup, error handling, and DOM effects while safely propagating failure.
Read how Functional Programming in JavaScript explains monad →
Learn Haskell by Example
A monad is an abstraction that sequences computations while encapsulating a computational context.
- How it is used
- Enables parsers to choose later parsing steps from earlier results and handle failures through composition.
- How deep it goes
- Defines Monad operations, demonstrates Maybe and do notation, and implements a Monad instance for a custom parser.
- Examples
- Uses Maybe calculations, monadic addition, a Hello World parser, integer parsing, and conditional PNM headers.
- What you can do after
- Build it from scratch by defining bind behavior for a parser and using do notation for dependent parsing.
Functional Programming in C#, Second Edition
A computational structure that provides operations for composing computations in a context, including operations commonly called Bind and Return.
- How it is used
- Uses monads to compose context-returning functions without accumulating nested structures.
- How deep it goes
- Explains Return, Bind, Map, and LINQ implementations, and names the identity and associativity laws.
- Examples
- Uses optional integer parsing, sequence pairs, and Task-based asynchronous operations to demonstrate composition.
- What you can do after
- Apply it via LINQ to combine optional values or sequence computations using SelectMany.
Read how Functional Programming in C#, Second Edition explains monad →
The Coder Cafe
A monad is an abstraction that represents computations with context and provides operations for sequencing those computations while preserving the context.
- How it is used
- Sequences context-wrapped computations when later steps depend on earlier results.
- How deep it goes
- Works through Maybe binding, short-circuiting, and do notation, while leaving I/O monads at a mention.
- Examples
- Demonstrates safe division, incrementing Just 42, and greeting only after age validation.
- What you can do after
- Apply Haskell’s >>=, return, and do notation to chain Maybe computations that stop when validation returns Nothing.
Type-Driven Development with Idris
A programming abstraction that provides operations for sequencing computations whose results determine subsequent computations.
- How it is used
- Provides a common interface for sequencing computations and using do notation across different structures.
- How deep it goes
- Develops bind implementations and interface dependencies for State, while giving join less detailed treatment.
- Examples
- Uses Maybe failure propagation and a State computation that totals positive integers from a list.
- What you can do after
- Build it from scratch for a custom State type and use generic sequencing functions with that implementation.
Read how Type-Driven Development with Idris explains monad →
Fabulous Adventures in Data Structures and Algorithms
A monad is an abstraction that pairs a type with operations for lifting values and chaining context-aware computations while preserving the structure of composition.
- How it is used
- Structures workflows that carry capabilities such as nullability, laziness, asynchrony, observation, or sequencing.
- How deep it goes
- Develops Unit, Map, Bind, and Join with C# transformations, but stops short of spelling out the monad laws.
- Examples
- Uses Nullable<T>, Lazy<T>, Task<T>, IEnumerable<T>, division by two, nested lazy values, and discrete distributions.
- What you can do after
- Apply it via Unit and Bind to transform ordinary workflows into workflows carrying nullable, lazy, asynchronous, sequence, or probabilistic behavior.
Read how Fabulous Adventures in Data Structures and Algorithms explains monad →
Functional Design and Architecture: Examples in Haskell
A monad is an abstraction that sequences computations while encapsulating a computational context such as optionality, state, errors, or input-output effects.
- How it is used
- Sequences effectful computations while keeping optionality, state, errors, and input-output concerns explicit.
- How deep it goes
- Defines monads through contexts and examples, then applies Maybe sequencing, while deferring deeper study to monad transformers and extended examples.
- Examples
- Uses Maybe-based user lookups, nested case expressions, do notation, and free monadic domain-specific scripting.
- What you can do after
- Apply monadic sequencing to simplify computations that carry failure or other computational effects.
Read how Functional Design and Architecture: Examples in Haskell explains monad →
Also covered in
What to know first
- functorA functor is an abstraction that maps values or objects while preserving the structure and relationships of their surrounding context.
- optionAn option type is a type that represents either a value of a specified type or its absence as distinct alternatives.
- side effectA side effect is an observable change or interaction caused by a computation beyond producing its direct result, such as modifying state or interacting with the external environment.
- functional programmingFunctional programming is a programming paradigm that expresses computation through the evaluation and composition of functions, typically favoring immutable data and minimizing mutable state and side effects.
Related concepts
- applicative functorcontrasts with · An applicative functor is a functor with operations for applying a function in a computational context to a value in that context and combining the computations.
- functorkind of · A functor is an abstraction that maps values or objects while preserving the structure and relationships of their surrounding context.
- flatmapuses · FlatMap is an operation that maps each element to a sequence or computational context and combines the resulting sequences or contexts into a flattened result.
- optionincludes · An option type is a type that represents either a value of a specified type or its absence as distinct alternatives.
- type-lifting functionuses · A type-lifting function embeds a value into a corresponding computational context, container, or type, often a monadic type.
- associativityuses · Associativity is the property of a binary operation whereby regrouping its operands does not change the result.
Questions about monad
What is monad?
A monad is a programming abstraction that provides operations for sequencing computations while encapsulating and preserving their computational context.
Which Manning books explain monad?
Functional Programming in Scala, Second Edition, The Joy of JavaScript, Functional Programming in JavaScript, Learn Haskell by Example, Functional Programming in C#, Second Edition, The Coder Cafe, Type-Driven Development with Idris, Fabulous Adventures in Data Structures and Algorithms and 1 more.
What should I know before learning monad?
Manning books that teach monad usually introduce functor, option, side effect and functional programming first.
What is the difference between monad and applicative functor?
A monad is a programming abstraction that provides operations for sequencing computations while encapsulating and preserving their computational context. An applicative functor is a functor with operations for applying a function in a computational context to a value in that context and combining the computations.
What kinds of monad are there?
Kinds of monad include option.
What is monad a kind of?
Monad is a kind of functor. A functor is an abstraction that maps values or objects while preserving the structure and relationships of their surrounding context.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.








