Add folly::Expected, an alternative to exceptions for non-throwing APIs that can fail.
Summary:
Expected is like an Optional with extra state for reporting //why// the Expected is empty. Something like it is currently under review for inclusion in the C++ standard [1], and Andrei Alexandrescu has spoken about it [2]. It corresponds to the Either Monad in Haskell, where it is used as a return type of an API that has more than one failure mode.
By adding folly::Expected, we get a way to implement non-throwing APIs with a consistent and composable interface.
[^1]: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4015.pdf
[^2]: https://channel9.msdn.com/Shows/Going+Deep/C-and-Beyond-2012-Andrei-Alexandrescu-Systematic-Error-Handling-in-C
Reviewed By: mhx
Differential Revision:
D3522501
fbshipit-source-id:
48b8ea2dfbd0769f26ec84d2d52fd41db75dc05a