Open
Description
Can we introduce type signatures using plain javascript?
Used to take all arguments to their respective types. (Use with casting functions like obj, etc…)
typedfn = (types, fn) => (...args) => fn(...map(zip(types, args), (t, v) => t(v))));
typecasg = (fn, types) =>
But typefn should correctly indicate function arity.
e.g.
addNumbers = typedfn([Number, Number], plus);
concatStrings = typedfn([String, String], plus);
This constricts arbitrary argument types by casting them into the correct type.