3 ms·
What is a result monad?
by all2 3y ago
What is a result monad?
- avgcorrection 3y agoIt is linguistically related to the (plus, int) monoid; the fact that it conforms to some algebraic/categorical interface is irrelevant in most contexts and just a distraction. (A “Result” is Rust-speak for a sum type which is either A or B, where (say) B is conventionally an error)
- ed_blackburn 3y agoThe result package in the article: https://github.com/rustedpy/result https://github.com/rustedpy/result There's a pretty decent explanation in the readme. If you're more interested in Monads, I am not sure I'd cover that in a HN comment very well, but I would encourage you to take a look.
- itishappy 3y agoIt just lets you combine results in an intuitive way: Ok(2) + Ok(3) = Ok(5) Ok(2) + Err() = Err() Err() + Ok(3) = Err()