Closed davidchambers closed 8 years ago
This approach seems sound to me. I like the idea of being explicit about the number of parameters you are expecting in the supplied function. More often these days I'm starting to see variadic functions and function context as distracting and occasionally problematic features of JavaScript.
Currently,
encase
andencaseEither
have misleading type signatures:They are misleading because Hindley–Milner notation cannot represent a function which returns a curried function of unknown arity.
In addition to the documentation problem, there's a usability problem. Functions with unwanted optional arguments must be wrapped in lambdas. For example:
A solution to both problems is to have one function for each arity up to some arbitrary limit:
An incidental benefit of this approach is that arguments to the wrapped function may be provided up front. For example: