5 comments

[ 2.1 ms ] story [ 23.7 ms ] thread
I'm not super familiar with Rust or MyPy, but I was wondering if you could mention what the distinction is between returning a Result vs e.g. a type hint for returning an exception
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.

Ohh I see. That's pretty cool, reminds me of Maybe monad from Haskell.
Maybe 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.

Can anyone say how this would work with pattern matching? Something for that page to address perhaps