Lambda polymorphism as a natural transformation

In my last post I proposed seeing lambda polymorphism as a bifunctor, but this notion seems tio weak. Lambda polymorfism really needs three inputs, but one of them doesn't seem to involve any data in the set sense, only type data, connecting the types. I've tried making this into a category that defined every possible input as an arrow to the right output, but it didn't turn out nicely. 

Instead I'm thinking of turning lambda polymorphism into a natural transformation. This seems promising, because as we all know, a parametrically polymorphic function is always a natural transformation. I will only scetch an example. The Church numeral 4 is applied to the Church numeral 3. Without polymorphism, this would not be possible, because 4 expects a signature * -> * in its first argument, but 3 has signature (* -> *) -> * -> *. We solve this by going by a * -> * functor before we apply the 3. 

The * -> * functor is super simple. It takes every signature S to a signature T where T is exactly what you get if you replace every * in S with (* -> *) and remove any extraneous parentheses that would be implied by the right associativity of ->. Arrows are equally easy. Just pick the arrow indicated by the original function. 


Now, in order to be applied to 3, 4 goes by the * -> * functor from its original signature (* -> *) -> * -> * to ((* -> *) -> * -> *) (* -> *) -> * -> *. Since 3 has the same signature as the first argument, the application is valid, returning the remaining (* -> *) -> * -> *. As expected, this is a Church numeral, incidentally 3^4 = 81. I'll explain why later, but there is a half hearted explanation on Wikipedia.

Remains to see if this definition proves fruitful.

The natural transformation I am talking about goes from the identity functor to the polymorphism functor (* -> * in this case). The arrow of the identity functor "remembers" that this the element 4 in the set of Church numerals. 3 will have to be pointed out somehow in the domain pointed out by the natural transformation. This way, the natural transformation can "store" both it's function and it's input in the point of its output. I think I might have to redefine the arrows of the category for this to work, though. I will get back to that.

Kommentarer

Populära inlägg i den här bloggen

The category of lambda calculus with products and coproducts

The Lambda Polymorphism (bi?) functor

The universal arrow of the exponential object for combining function and input