scriptum icon indicating copy to clipboard operation
scriptum copied to clipboard

Allow typing variadic functions

Open ivenmarquardt opened this issue 4 years ago • 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.

ivenmarquardt avatar Nov 19 '21 11:11 ivenmarquardt

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..

ivenmarquardt avatar Dec 09 '21 21:12 ivenmarquardt