Open
Description
Description
I want to implement a variadic version of the currying function.
func curried<First, each T, Result>(
_ originalFunc: @escaping (First, repeat each T) -> Result
) -> (First) -> (repeat each T) -> Result {
return { (first: First) in
return { (remanings: repeat each T) -> Result in
return originalFunc(first, repeat each remanings)
}
}
}
The error message is:
error: cannot fully abstract a value of variadic function type '(repeat each T) -> Result' because different contexts will not be able to reliably agree on a calling convention; try wrapping it in a struct
error: cannot fully abstract a value of variadic function type '(repeat each T) -> Result' because different contexts will not be able to reliably agree on a calling convention; try wrapping it in a struct
I have no idea what it means by " try wrapping it in a struct", it seems unrelated.
Environment
- 1.87.1 Apple Swift version 5.9 (swiftlang-5.9.0.128.108 clang-1500.0.40.1)
- Xcode 15.0 (15A240d)