C++ Logo


Advanced search

[std-proposals] Lack of monadic operations in 'std::expected'

From: Shiroki Satsuki <shirokisatsuki_at_[hidden]>
Date: Wed, 19 Oct 2022 02:27:09 +0800
'std::expected' adds a nice way of handling errors without using the
exception system and will be included in C++ 23. 'std::optional' is
going to have monadic operations in this version too.

However, the current 'std::expected' proposal
(https://wg21.link/p0323r10) makes no mention of monadic operations,
neither 'transform' (aka 'map') nor 'and_then' (aka 'bind' or
'flatMap'). A generic associated types 'rebind<U>' is included, though.

It would be a pity if functional programming lovers must wait until C++
26 for a complete 'Either' monad.

Received on 2022-10-18 18:27:22