infernu
infernu copied to clipboard
Find a way to represent monotyped functions with optional 'this'
Functions such as:
function f(x) { return x; }
Don't require 'this' and so are generalized over it, to get type forall a. a(b -> b)
Sometimes such functions can't be generalized and become monotypes. In this case, the 'this' argument is locked-down to the first usage's type. Find a way to make it more flexible. (Tried a simple subtyping rule on 'undefined' but that breaks a lot of guarantees)
Probably correct solution is to allow (properly typed) optional params in general.