Back to Basics: Functional Programming and Monads in C++
Talkat CppCon 2024 · on Thursday, 2024-09-19· at 09:00· Maple 3/4/5, 6700 North Gaylord Rockies Boulevard·
summary
Argues that real benefit is concrete composition: use std::ranges and views and generators to build lazy pipelines (iota, transform, filter, join, zip, product, chunk_by) that avoid intermediate containers; use std::optional/std::expected with transform/and_then/transform_error to propagate failures without nested ifs; switch to imperative or generators when naive recursion is exponential (Fibonacci); implements a conditional_range to avoid allocations; composes senders/receivers for async work and executes with sync_wait — examples run and the patterns hold.
AI-written summary · about
chapters (19)
- 0:00Introduction
- 0:27Imperative vs declarative
- 2:03Functional programming basics
- 3:42Functional programming in C++
- 5:12Composing algorithms
- 7:50Lazy composition with views
- 10:43Common range patterns
- 11:59Advanced range generation
- 16:30Combining multiple ranges
- 19:24Chunking and windowing
- 23:13Flattening and joining
- 25:58Summary of algorithm composition
- 29:21Composing optional values
- 35:05Optionals and ranges in C++26
- 37:15Debugging pipelines
- 38:37Handling fallible operations
- 44:41Pure functions and I/O
- 48:50Parallelizing actions
- 50:55Conclusion and monads
related talks
31mLet's get Functional (en)
47mPrinciples of Clean Functional Programming
01h 02mFunctional Programming for the Everyman
52mHigher Order Functions for ordinary developers
33mThe First Few Sips
53mMaintainable JavaScript with Functional Patterns
45mFree Your Monads and the Rest Will Follow
51mSimplicity: Not Just for Beginners
