Lecture: Monads in Modern C++

Monads are a common technique in functional programming languages to reduce boilerplate, abstract detail in order to produce simple, pure pipelines. While traditionally associated with languages like Haskell, monads are making their way into more mainstream languages, including C++ -- with monadic operations being added in C++23. In time, these functional techniques may become core pillars of C++ development.

To many developers, monads are either unknown or confusing -- they have a reputation as being notoriously difficult to understand. This talk, which will combine both theory and coding examples, aims to demystify the monad and enable attendees to gain insight into its internal workings.

While the focus of our talk will be on C++, the ideas are relevant to any other programming language -- the shift towards these functional features is not unique to C++.

No functional programming knowledge required.

This talk will serve as an introduction to the monad design pattern. We will start by introducing functors (a related pattern) and use it as a building block to introduce monads. Throughout the presentation, we will show examples of how monadic operations can help turn our imperative-style code into succinct functional pipelines, while removing boilerplate, error-prone control flow, and side effects. The examples will relate to recent and upcoming developments for std::vector and std::optional in the C++ standard. Finally, the talk will incorporate a walk-through of the available monadic support in C++, and we will discuss where C++ stands in comparison to other languages.

Info

Day: 2023-04-21
Start time: 14:00
Duration: 01:30
Room: Bristol I
Track: Modern C++

Links:

Feedback

Click here to let us know how you liked this event.

Concurrent Events