Applicative: The Forgotten C++ Functional Pattern - Ben Deane - CppCon 2023

Discover the forgotten C++ functional pattern, Applicative, and learn how to use it to improve code readability, maintainability, and concurrency. From partial application to variadic fmap, explore the key features and benefits of Applicative in C++.

Key takeaways
  • Applicative is a functional pattern that is often forgotten in C++ programming.
  • In Haskell, applicative is applied lazily by default, whereas in C++ it requires explicit implementation.
  • Partial application is a key feature of applicative, allowing functions to be composed in a modular way.
  • The fmap function is a fundamental part of applicative, allowing functions to be applied to functorial values.
  • Variadic fmap is particularly useful in C++ because it allows functions to be applied to multiple arguments.
  • Applicative can be used to implement monadic operations in a more declarative way.
  • The join function is used to combine multiple applicative values into a single value.
  • Cartesion product is a key feature of applicative, allowing multiple values to be combined into a single value.
  • Applicative can be used to implement concurrency in C++.
  • P2300 is a paper that proposes adding an error propagation operator to C++.
  • Applicative is often confused with monad, but it has distinct properties and uses.
  • Functors, applicatives, and monads are all important functional patterns in C++ programming.
  • Readability and maintainability of code can be improved by using functional patterns like applicative.
  • Closures are important in functional programming, allowing functions to capture and return values.
  • Lazy evaluation is used to optimize the evaluation of expressions in functional programming.