cpprussia C++ Russia 2019 Msc (19.04.2019 — 20.04.2019)

Monadic parsers

img

We’ll discuss monadic parsers: what’s the difference between this parsing approach and the other ones, what are its advantages and disadvantages, and what’s the role of such important concepts of functional programming as functors, applicative functors, and monads.

A frequent question in the C++ developer community is: "Who does even need monads?" There are common examples of monadic use of types like std::optional, std::future, and std::expected, but list of monads most frequently used in the functional programming world is much more longer. For example, in Haskell there are the following monads: Maybe (std::optional), Either (std::expected), IO, State, Reader, STM, Par (std::future). But instead of trying to grasp what a monad is and how does it work, it might be more useful to learn how to use specific monads and which tasks they solve, getting this way a basic understanding that could be applied for any monad.

In this session, we’ll discuss monadic parsers: what’s the difference between this parsing approach and the other ones (parser combinators such as Boost::Spirit, parser generators, ad hoc solutions — for example, parser finite state machine, etc.), what are its advantages and disadvantages, and what’s the role of such important concepts of functional programming as functors, applicative functors, and monads.