support using co_await with folly::Optional when it is available
Summary: Coroutines can be used to simulate the monadic "do" notion of Haskell. Use coroutines to enable monadic composition with folly::Optional. ``` Optional<int> f() { return 7; } Optional<int> g(int) { return folly::none; } void MonadicOptional() { Optional<int> r = []() -> Optional<int> { int x = co_await f(); assert(x == 7); int y = co_await g(x); assert(false); // not executed co_return y; }(); assert(!r.hasValue()); } ``` Reviewed By: yfeldblum Differential Revision: D5763371 fbshipit-source-id: 9babc682244f38da7006d0b3a8444fd4efec1747
Showing
Please register or sign in to comment