8 ms·
The real "revelation" of this method of error handling is how it uses types to explicitly state how errors are handled. Having a return type of `Either String I
by jecxjo 8y ago
The real "revelation" of this method of error handling is how it uses types to explicitly state how errors are handled. Having a return type of `Either String Int` let's the user know that this function does in fact have an error case that would potentially be short circuited to a far off error handlers, and that a `String` is the type returned on an error.
In most other languages you either don't know if an exception could be thrown or you just assume every function throws one. Then when you are adding in things like promises which explicitly define success and failure paths the system must implicitly catch all exceptions and pass them to your error path...unless the developer chooses to change that functionality.
Much nicer to have all that defined for you in the type system, even though it existed without it.