Tag: algebra

What Happens in Monads Stays in Monads

There are moments in life when you have to take a stance. You know countless people already tried and possibly succeeded in doing something, but you feel the urge to try it yourself.

So yesterday I attended the Milan C++ Meetup by Marco Arena, presented in a very entertaining and well-organized way, what’s new in C++23. Everything was fine until Marco presented the std::expected template and its “monadic operations”. Now it was in the context of a much wider presentation and there was no time to go into details, but I got the impression that the C++ community has a bit of an ad-hoc approach to monads. I mean C++98 failed to recognize that containers are monads, C++11 failed to recognize that std::future is a monad, C++17 failed to recognize that std::optional is a monad, and C++20 failed to recognize that coroutines are monads. You can see a pattern there.

Continue reading “What Happens in Monads Stays in Monads”

Unfrightening Catamorphism and Anamorphism

TIL what Catamorphism and Anamorphism, and about a new useful function. Functional programmers are not shy to use mathematical terms that could frighten the casual programmer listening. Functor, monoid, applicative just to name the first that comes to mind. Usually, they turn out to be relatively simple concepts (which get combined together until they are no longer simple).

Continue reading “Unfrightening Catamorphism and Anamorphism”