Open koraa opened 4 years ago
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.
Can we introduce type signatures using plain javascript?
Used to take all arguments to their respective types. (Use with casting functions like obj, etc…)
But typefn should correctly indicate function arity.
e.g.
This constricts arbitrary argument types by casting them into the correct type.