3 ms·
Only if your language supports dependent types.
Only if your language supports dependent types.
In Ada, you can define integer types that only accept a given range of values.
It's perfectly possible in languages with ordinary ADTs.
data Nat = Z | S Nat
data NonZeroNat = OnePlus Nat
data NonZeroInt = Negative NonZeroNat | Positive NonZeroNat