Getting started with the Reader Monad in C++

Tornano i meetup C++ in presenza realizzati dall’Italian C++ Community e ospitati da ConoscereLinux!

Ogni incontro prevede la condivisione di un argomento, spazio per le domande e poi una pizza tutti insieme. Il formato della presentazione può variare ed è deciso dal relatore ospite della serata: talk frontale, workshop, live coding, ecc.

Gli incontri, come avveniva prima dell’emergenza sanitaria, saranno trasmessi anche in diretta streaming. Per interagire con il resto della community, richiedi (se non ce l’hai già) l’accesso al nostro team slack ed entra sul canale #meetup-modena.

La sessione

Functional programming (FP) has successfully entered C++ via the Range-v3 library / C++20 Ranges. This technical session looks at a more advanced aspect of functional programming, namely monads. Monads in functional programming fulfill a great range of functionalities and the Reader Monad, presented in this talk, roughly models the dependency injection idiom in C++.

In the first part of the talk, I will provide an overview of monads in general, their functionalities, and equivalents in C++. Next, I will present the interface of the Reader monad and its uses in real-world scenarios such as the dependency injection. This will be followed by an implementation of the Reader monad in terms of generic lambda expressions. Here I will clarify what constitutes a monad and what the particulars of the Reader monad are. Finally, we will use our implementation in conjunction with concrete input arguments.

If time allows, we will go through exercises that involve generic nested lambda expressions useful for rolling out your very own monads.

Prerequisites: To follow the talk, It helps if you can interpret basic generic nested lambda expressions. You don’t need to know about monads. No external library will be used. The presented code will work under any C++14 supporting compiler.

La relatrice

Ruzena Gurkaynak. I am the founder of Walletfox.com, a functional programming specialist, and the author of the book Fully Functional C++ with Range-v3. I have 15+ years of experience in developing desktop-based applications in Qt / C++ with the predominant focus on 2D computer graphics. I admire the work of Edsger W. Dijkstra and believe in unassuming explanations, especially in C++. I am always happy to take questions, I will research thoroughly and get back to you with an answer.

Video e materiale dell’evento

Le slides sono a questo link.

Se desideri seguire la diretta YouTube e partecipare da remoto:

Quando: