Arity is the number of arguments a function accepts. In a functional pipeline, a receiving function must declare at least one parameter so it can handle the previous function’s output. section 4.2
Arity in a typed tuple
A tuple can enforce arity by comparing the number of supplied values with its declared types. Constructing a two-value StringPair with three values therefore raises an arity mismatch. section 4.2
Listing 4.2. Typed Tuple data type
const Tuple = function( /* types */ ) {
const typeInfo = Array.prototype.slice.call(arguments, 0); #1
const _T = function( /* values */ ) { #2
const values = Array.prototype.slice.call(arguments, 0); #3
if(values.some((val) => #4
val === null || val === undefined)) {
throw new ReferenceError('Tuples may not have
any null values');
}
if(values.length !== typeInfo.length) { #5
throw new TypeError('Tuple arity does not
match its prototype');
}
values.map(function(val, index) { #6
this['_' + (index + 1)] = checkType(typeInfo[index])(val);
}, this);
Object.freeze(this); #7
};
_T.prototype.values = function() { #8
return Object.keys(this).map(function(k) {
return this[k];
}, this);
};
return _T;
};
Inspect the Tuple implementation’s length check for a concrete runtime treatment of arity. section 4.2




