3 ms·
There are sum types, and product types, but what would "exponentiation types" look like?
by amelius 6y ago
There are sum types, and product types, but what would "exponentiation types" look like?
- pwdisswordfish4 6y agoThose are just (pure) function types.
- Someone 6y agoFixed-length sequences, but they would be constructed from a type and a non-negative integer, not from two types. The sum of a type with m possible values and a type with n possible values has (m+n) possible values, the product of a type with m possible values and a type with n possible values has (m×n) possible values, a sequence of n items of a type with m possible values has m^n possible values.
- guerrilla 6y agoExponential types are functions [1]. The type A -> B could be written B^A. Interestingly, if you take functions to be lookup tables, then that's related to the number of possible unique lookup tables. First, notice that the type A + B has |A| + |B| values, the type A × B has |A| + |B| values and then we can see that A -> B has |B|^|A| values by remembering that functions can be seen as binary relations with the property of being functional. This means that there are |B|^|A| possible unique functions. Try an example by counting the number of functions from the set { 0, 1 } to { 2, 3, 4 }. You will see that there are 3^2 = 9 possible unique functions. 1. https://en.wikipedia.org/wiki/Function_type https://en.wikipedia.org/wiki/Function_type
- amelius 6y agoInteresting! Now I wonder what "tetrated" types correspond to [1] [1] https://en.wikipedia.org/wiki/Tetration https://en.wikipedia.org/wiki/Tetration
- guerrilla 6y agoWell, I don't know of any type theory that has that but you could make something up. C^(B^A) = (B^A) -> C = (A -> B) -> C. So you'd get nested higher-order monomorphic functions like if the base is A and the height |B| = 5 then the result of tetration would be (((A -> A) -> A) -> A) -> A. I don't really know what that means though. Maybe an expert Haskeller could recognize a pattern.