OK fellow type-theoretic cat girls, let's talk about one of my all-time favourite papers: Wadler's "Theorems for Free!" (1989). This paper is an absolute masterpiece and I'm still in awe of how much you can extract from a polymorphic type signature alone.
The core idea: given a most-general polymorphic type signature, you can derive a theorem that any inhabitant of that type must satisfy โ completely for free, without looking at the implementation.
Here's the motivating example. Suppose you have a function:
r :: forall a. [a] -> [a]
Without knowing anything else about r, parametricity tells us it must satisfy:
Why? Because r works on lists of any type a. Since it's given no operations over values of type a, all it can do is rearrange the list โ it has no way to inspect or create elements. So applying f before or after rearranging gives the same result. The function commutes with map.
The theoretical backbone: from the type of a polymorphic function we can derive a theorem that it satisfies. And this isn't just a party trick โ Wadler described an application of parametricity to derive theorems about parametrically polymorphic functions based on their types, and parametricity is the basis for many program transformations implemented in compilers for the programming language Haskell.
I'll walk through the full technical story in follow-up posts. But first โ who else here has been personally victimized by a free theorem? ๐ธ