Then you end up with a pyramid of doom. Fine for small examples but it doesn't scale up easily.
Rust has special syntax (`?`) for this AFAICT.
Rust has special syntax (`?`) for this AFAICT.
Short circuiting on `Either` is a specific case of this. You can define your own EitherBind in any language.
eitherBind :: Either e a -> (a -> Either e b) -> Either e b
eitherBind (Left e) _ = Left e
eitherBind (Right a) f = f a
Now you can bind over Either to your heart's content without needing an encoding of Monads in your language.Let's consider a language like C++ where it has none of those syntax sugars. The absl::StatusOr is a class with the idea that errors should be values. The standard library has std::expected since C++23. So where is your pyramid of doom?