Monadic Operations in Modern C++: A Practical Approach
summary
Uses C++23 std::expected and std::optional plus ranges and the TL expected implementation for older toolchains to replace error-code/boolean returns in a real internal UI framework for a commercial ink tablet; chains load-and-add-window operations, transforms error types with transform_error, and recovers with bind_back/bind_front to add context. Claims: one year of production use, fewer boilerplate checks, safer error propagation, and stepwise refactor path from private impl to public monadic APIs; reports it largely works in practice.
AI-written summary · about
chapters (27)
- 0:00Monadic operations in C++
- 1:08Expected and optional overview
- 6:07Practical optional use cases
- 10:04Expected for error handling
- 12:10Monadic operations examples
- 14:38Pitfalls in monadic error handling
- 15:00Monadic operations in production
- 19:18Monadic chain evaluation
- 20:04Functional C++ design
- 22:32Resistance to monadic patterns
- 24:22Mixing functional and imperative
- 25:46Boundaries for functional code
- 27:30Case study: Window layout class
- 31:22Refactoring to monadic interfaces
- 35:15Controversial monadic tips
- 35:56Reducing lambda complexity
- 39:31Bind back and bind front
- 41:42When to use bind back
- 45:15Readability vs flexibility
- 46:19Team consensus on monads
- 47:25Namespace and capture in bind
- 49:01Composable types return
- 50:48Tuples and pairs in monads
- 51:10Transforming error types
- 52:13Adding error context
- 53:17Third-party functional libraries
- 54:02Q&A
related talks
01h 35mMongrel Monads, Dirty, Dirty, Dirty
58mMonoids, Monads, and Applicative Functors: Repeated Software Patterns
01h 07mDesign Patterns in Modern C++
55m“Using Types Effectively"
01h 00mThe Dawn of a New Error
51mKeynote: There Is No Silver Bullet to Solve All C++ Software Problems
01h 28mModern C++ Design reloaded
46mPractical Functional Programming in C++
