kongware/scriptum

Allow typing variadic functions

ivenmarquardt opened this issue · 1 comments

The following term has currently no type in scriptum, because the passed arguments might be heterogeneous and thus potentially creating an heterogeneous array:

f => (...args) => args.reduce((g, arg) => g(arg), f)

Since this a widespread pattern in Javascript it should be possible to type it.

I think the underlying problem is that rest syntax is typed as [a] but it should be typed as a tuple. The problem is that the tuple type is not known at validation time, because it depends on a dynamic value. Maybe this is some sort of dependent type. Further dwelling required..