I think I’ve previously stated that I don’t believe Rust’s built-in math operators (Div, Add, Mul, etc) should be effectful.
Reading a paper right now where they did *exactly* that (Lutze, Madsen, 2024), and swapping out panics for concrete errors is super useful!:
- division by zero for floats results in NaN, which means Div for floats can be marked as Pure.
- checked integers return concrete errors rather than panic on overflow. This essentially swaps a “panic” effect for a “try” effect.