I have a need to enforce safe overflow handling via type system, and had an idea for "monadic overflow handling". In essence: one can keep using a value that might or might have not overflown already, and only at the end of computation, check overflow status. Kind of line NaN but for integer overflow.
I wasn't able to find anything like this before. There's checked and there are some other crates based on macros and compiler plugins.
Since this is very much a proof of concept, feedback very welcome. In particular about existing crates that I've missed that are either doing just this, or maybe something better.
One interesting thing to point out is that the question mark operator is do-notation for the monad Option. Hence you can do what you're doing with the question mark operator like this: