Is there a way to spread a tuple into the arguments of a function?

Also, have a look at Is Implicit Tuple Splat behavior not fully removed?

Very interesting! I don't have to make my function generic for input, it can take a single argument.

// this works
func tuplify<I, O, F>(_ f: @escaping (I) throws(F) -> O) -> (I) throws(F) -> O { f }
func test(_: Int, _: Int, _: Int) {}

tuplify(test)((1,2,3))

However, the following fails with the following error:

  • Cannot convert value of type (repeat each Arg) throws(Failure) -> Result to expected argument type ((repeat each Arg)) throws(Failure) -> Result
  • Pack expansion requires that (repeat each Arg) and each Arg have the same shape
func call<each Arg, Result, Failure>(
	_ f: @escaping (repeat each Arg) throws(Failure) -> Result, with args: (repeat each Arg)
) throws(Failure) -> Result {
	tuplify(f)(args)
}