Applicative: The Forgotten C++ Functional Pattern
Talkat CppCon 2023 · on Wednesday, 2023-10-04· at 14:00· Adams, 6700 North Gaylord Rockies Boulevard·
summary
Shows a concrete implementation: variadic fmap/apply for std::optional and std::expected, a lazy-call wrapper to avoid eager eval, and a Cartesian-product applicative for ranges and tuples that replaces many overloads with one variadic template. Microbenchmarks show the optimizer collapses the wrappers so performance matches handwritten code. Uses parsing examples (quote and hex parsers) and maps p2300 senders/receivers to applicative primitives; the prototypes compile and behave as intended.
AI-written summary · about
chapters (11)
- 0:00Functional patterns in C++
- 1:55Applicative overlooked
- 9:12Haskell vs C++ applicative
- 17:42Error propagation with applicative
- 27:14Implementing std::expected applicative
- 36:28Applicative vs monad
- 39:25Applicative in C++ ranges
- 46:23List comprehensions
- 51:03Applicative in parsing
- 56:21Applicative with P2300
- 59:33Conclusion & Q&A
related talks
58mThe Imperatives Must Go! [Functional Programming in Modern C++]
01h 09mFunctional Programming in C++
53mProduct Types for C++2x
09mstd::optional and the m word
01h 02mFunctional Composable Operations with Unix-Style Pipes in C++
01h 10mThe Three Little Dots and the Big Bad Lambdas
53mReduce: From functional programming to C++17 Fold expressions
59mFunctional Programming: data
