4 ms·
Theorems for Free tells you that some abstractions satisfy some mathematical properties (for free!) under some circumstances. If you write down a function with
by abstra4free 2y ago
Theorems for Free tells you that some abstractions satisfy some mathematical properties (for free!) under some circumstances.
If you write down a function with signature
{T : Type} -> T -> T
then it must be the identity function, if you do not use "malicious" extensions of the type system.
But what is the performance of the identity function?
Here is an identity function:
lambda T, lambda t, if (2 + 2 = 4) then t else t
In other words: I can hide pretty much arbitrary computation in my identity function.
Users of my identity functuon will notice that it is wicked slow (in reality, I let my identity function compute Busy Beaver 5, before doing nothing). Their complaints are evidence of leaky abstraction.
Now you might have a smart optimizing compiler that knows about Thm4Free... But that's another story.
- javcasas 2y agoI don't think you can have such compiler, at least for a general case, without solving the halting problem first. After all, you can encode arbitrary computations at the type level.
- VirusNewbie 2y agoThe point of the abstractions I'm talking about is not to abstract away the computation part of a program, it's to abstract away the types and complexities of the semantics.