33 #include "fp/_external/expected.hpp"
48 return std::optional<T>{value};
62 template <
typename T,
typename F>
63 constexpr
auto mbind(
const std::optional<T>& opt, F f)
64 -> decltype(f(opt.value())) {
66 return f(opt.value());
85 template <
typename T,
typename E,
typename F,
86 typename Ret =
typename std::result_of<F(T)>::type>
87 constexpr Ret
mbind(
const tl::expected<T, E>& exp, F f) {
89 return f(exp.value());
91 return tl::make_unexpected(exp.error());
106 template <
typename F,
typename Ret =
typename std::result_of<F()>::type,
107 typename Exp = tl::expected<Ret, std::exception_ptr>>
112 return tl::make_unexpected(std::current_exception());
127 template <
typename F,
typename G>
129 return [=](
auto value) {
return mbind(f(value), g); };
145 template <
typename T,
typename G,
typename... Types>
164 template <
typename T,
typename F>
165 constexpr
auto operator|(
const std::optional<T>& opt, F f) {
182 template <
typename T,
typename E,
typename F,
183 typename Ret =
typename std::result_of<F(T)>::type>
184 constexpr Ret operator|(
const tl::expected<T, E>& exp, F f) {