I'm surprised nobody mentioned co_await yet. This should be possible.
std::optional<int> foo();
And then
std::optional<int> bar(){
int x = co_await foo();
int y = co_await foo();
return x+y;
}No messy chaining or lambda pyramid of doom.
I'm surprised that the monadic ops and C++ co_await are not being aligned in the standard yet