The Scala standard library isn't going to help you generalize over arity in most cases, but Shapeless is perfect for this. Here's how you could write your function in Shapeless 1.2.4:
import shapeless._
def foo[F, P <: Product, A <: HList, R](f: F, p: P)(implicit
fl: FnHListerAux[F, A => R],
pl: HListerAux[P, A]
): R = fl(f)(pl(p))
And then:
scala> foo((i: Int, s: String) => s * i, (3, "a"))
res0: String = aaa
It looks complicated, but essentially you're just saying that you need evidence that a function f
of some arbitrary arity can be converted to a single-argument function from a heterogeneous list A
to the result R
, and that the tuple P
can be converted to a heterogeneous list of the same type.