This allows passing a callback with fewer params than is expected. This is to support things like array.map((x) => x) since the full callback accepts three params, e.g. array.map((x, index, array) => x).
The is a bug with the current implementation which is that we allow array.map((x, y, z, w) => x) which is undecidable by the type system since we also support partial application and we don't know how many args map applies to the callback.
One foo function is a subtype of another bar if:
foo has fewer params than bar, but the params it does have matches those in bar (or the params of bar are subtypes of the params of foo). This means that whatever the caller would normally pass bar would also be accepted by foo.
the return types match (or the return type of foo is a subtype of bar's return type). This means that whatever foo returns it conforms to the type that bar returns.
This PR doesn't allow subtype relations between the params or return types of foo and bar so there's more work to do.
This allows passing a callback with fewer params than is expected. This is to support things like
array.map((x) => x)
since the full callback accepts three params, e.g.array.map((x, index, array) => x)
.The is a bug with the current implementation which is that we allow
array.map((x, y, z, w) => x)
which is undecidable by the type system since we also support partial application and we don't know how many argsmap
applies to the callback.One
foo
function is a subtype of anotherbar
if:foo
has fewer params thanbar
, but the params it does have matches those inbar
(or the params ofbar
are subtypes of the params offoo
). This means that whatever the caller would normally passbar
would also be accepted byfoo
.foo
is a subtype ofbar
's return type). This means that whateverfoo
returns it conforms to the type thatbar
returns.This PR doesn't allow subtype relations between the params or return types of
foo
andbar
so there's more work to do.