If you’re interested in functional error handling in Scala (Option, Try, Either, etc.), there’s a nice discussion at this Github pull request.
There are a few quotes that are well worth sharing for anyone interested in functional error handling in Scala. First, all of Martin Odersky’s introduction is terrific background material on the topic, so I’d start with that.
Later, Adam Warski shares this statement, which I think is a terrific summary about functional error handling with ZIO:
Eithermight not be perfect, it's very commonly used for error-handling right now (next to exceptions). Even, or maybe especially, in purely-functional codebases, including ones based on ZIO: if a method it pure, it uses
Either, if a method is effectful, it uses
Finally, Mr. Odersky follows up part of Mr. Warski’s comment with this statement about
“Yes, no problem adding the same mechanism to
Either(even though it’s still an abomination 😁 as an error handling construct).”
I always appreciated the flexibility of
Either, but thought that its flexibility came at a certain price.
Please see that interesting discussion for more details. (It’s not often that you can easily see the inner workings of how a computer programming language is created and modified.)