51 ms·
An exception breaks the "instruction flow". While a Result type can be chained with functions like `map` and `map_or`. This allows you to write your full algor
by linkdd 6y ago
An exception breaks the "instruction flow". While a Result type can be chained with functions like `map` and `map_or`.
This allows you to write your full algorithm/computation, and handle the final result afterwards.
- pizza 6y agoOhh I see. That's pretty cool, reminds me of Maybe monad from Haskell.
- linkdd 6y agoMaybe because Result is a monad, an Either monad to be precise. Monads have been implemented in many languages without the developer even knowing, the best example IMHO are Javascript's Promise which are Continuation Monads.