Idk, to me that constant
Result<User, Error>
looks extremely ugly and unergonomic, even just to type.I understand that this is complicated topic and there were a lot of strong opinions even inside of Google about it, but god, I miss absl::StatusOr and ASSIGN_OR_RETURN. Yes, it won’t work without preprocessor magic (and that’s why this article goes through heavy functional stuff, otherwise it just cannot work in language like C#), but it’s so easy and natural to use in base case, it feels like cheating.
Is this similar? https://github.com/amantinband/error-or
What's some of the "preprocessor magic" that makes this[1] more ergonomic to use?
[1]: https://github.com/abseil/abseil-cpp/blob/master/absl/status...
> I miss absl::StatusOr
Sounds like you would rather have an `ErrorOr<User>` than a `Result<User, Error>`.
Both are union types wrapped in a monadic construct.
I think in C# the way to solve this is to have two separate types, `Ok<TValue>` and `Err<TError>`, and provide implicit conversions for both to `Result<TValue, TError>`.
The static method approach showcased in the article is really long-winded.