Everyone knows an elegant way to express natural numbers in functionally dependent languages:
data Nat = Zero | Succ Nat
The integer, fraction, real, complex and quaternion are also very important for practical programming. They could be implemented as:
data Integer = Integer (sign : Bool) (modulus : Nat) data Fraction = Fraction (dividend : Nat) (divisor : Nat) data Real = Real (exponent : Integer) (fraction : Nat) data Complex = Complex Real Real data Quaternion = Quaternion Real Real Real Real
But not one of them really reflects the actual structure / nature of their types as significant as the Nuts does. An integer is not isomorphic to real integers, for example (since Zero occurs twice). Realities need more than a million cells to store (3.141592), but not even 100 to store (4096), which looks unbalanced. The Complex is just a Reals tuple that does not really reflect what the Complex is. Interestingly, what is a natural, elegant way to express a number tower in functional programming languages?
source share