5 ms·
> For example, what is the type signature for subtraction of two NonZeroNumbers? You can't guarantee that it isn't zero, so it has to be a Number. You can enco
by naasking 3y ago
> For example, what is the type signature for subtraction of two NonZeroNumbers? You can't guarantee that it isn't zero, so it has to be a Number.
You can encode this failure as well, so at least the possibility becomes explicit:
NonZero -> NonZero -> Either NonZero Number
Oleg also showed you can make an even safer statically checked version with pretty standard type theory and modules:
https://okmij.org/ftp/Computation/lightweight-guarantees/lightweight-static-capabilities.pdf https://okmij.org/ftp/Computation/lightweight-guarantees/lig...