In languages that support currying, I can't think of many cases where using a tuple as function input parameters would be better than breaking the tuple apart into multiple parameters, which then allows you to enjoy the full power of currying. In which situations is keeping a tuple as function parameter better than breaking it apart? (Apart from the situation where the input originally was already in tuple form) Does such situation occur a lot in production code?
Why use tuples as function parameters in languages that support currying?
functional programming;scala;functions;higher order functions;currying
There's multiple reasons:Some functions will return tuples and it's useful to compose such functions directly with other functions that accept tuples.Often when values are bundled in a tuple they're conceptually one unit, i.e. you almost always pass all of them together. In other words, there's certain functions you wouldn't curry often.It's trivial to write functions that turn a tuple-accepting function in a curried function and vice-versa, so it's never a big issue even if you need to curry a tuple-accepting function.