3 ms·
I think moving the error around is a good idea. E.g. integer division would end up with five cases: Int / 0 -> DivisionByZeroError PositiveInt / PositiveI
by robertlagrant 28d ago
I think moving the error around is a good idea. E.g. integer division would end up with five cases:
Int / 0 -> DivisionByZeroError
PositiveInt / PositiveInt -> PositiveFloat
PositiveInt / NegativeInt -> NegativeFloat
NegativeInt / PositiveInt -> NegativeFloat
NegativeInt / NegativeInt -> PositiveFloat
And the type signatures of those possible return values can drive validation checks upstream of the calculation, so you're not actually ever going to return DivisionByZeroError. You're making sure through validation checks or case logic that that can never be returned.