Conceptually, I used to think of types as sets. However, I think I've seen people wishing to distinguish types A
, B
even if they represent identical collections of values. So I figured a better definition of type is a pair (type_name, set)
, where two different types cannot have the same first element.
Then I ran into a different situation. I thought a function is just a set of pairs (x, y)
. But then a function A->B
(where A, B
represent the same collections of values) cannot be distinguished from a function B->B
or A->A
or B->A
, and again I think I've seen people want to distinguish them. So how do I define a function? As a tuple (A, B, (x1, y1), (x2, y2), ...)
, where each element of A
appears exactly once as the first element in the pairs, and where each second element is of type B
?
And the type F
that represents all functions that takes A->B
is then (F, ((A, B, (a1, b11), (a2, b12), ...), (A, B, (a1, b21), (a2, b22), ...), (A, B, (a1, b31), (a2, b32), ...)))
, where a1, ...
are all the values represented by A, and b?1, b?2, ...
, for any ?
, are some of the values represented by B
.
This all seems rather cumbersome, am I missing something?