Defunctionalization and Freyd’s Theorem
bartoszmilewski.com
bartoszmilewski.com
Any suggestions for introductory material that might help me appreciate Milewski's writings?
https://bartoszmilewski.com/2014/10/28/category-theory-for-p...
> Product is functorial in both arguments so, in particular, we can define a functor L_a(c) = c * a.
Bartosz is saying that we can fix one side of the product, giving us a one-argument specialization that is a functor. In this case, we're fixing `a` (subscript binds tighter than parameters, in some sense) and letting `c` vary. That's what it means to be functorial in both arguments: fix either one and you get a functor.
The same phenomenon shows up in other fields where you have n-ary functions. Bilinear maps (in linear algebra) are linear in each argument. You could come up with something similar involving continuity in each argument for a binary function in real analysis (although I think that would actually be a weaker property than claiming the binary function is continuous...)
Sure, I could look it up, but my problem is that I spend all my time looking things up. At some point, this gets in the way of proper understanding. It's a strong signal that I'm missing some foundational knowledge.
(Your reply is most appreciated, though!)
The suggestion to use a combination of CPS + defunctionalisation to serialise closures is notable, since that pair of transformations gives a fairly close correspondence between a subset of the lambda calculus (plus some primitives) and abstract machine code. Some of the old-school Scheme compilers used CPS as a low-level IR for that reason.
I feel like this is a much deeper philosophical point worth pausing and pondering. (It's also very suggestive as to the whole point of defunctionalization -- nice foreshadowing!)
Functions happen to be things that your PL provides natively. Defunctionalization is all about capturing a piece of the global `apply` for functions, and translating it into an `apply` on a custom data type.