I'd like to write a variadic version of curry but every version I try gets rejected. Here's what seems like it should work:
func curry<A, each B, C>(
_ f: @escaping (A, repeat each B) -> C
) -> (A) -> (repeat each B) -> C {
{ (a: A) -> (repeat each B) -> C in
{ b in f(a, repeat each b) }
}
}
I've played around with some other forms, my favorite error message so far is:
Cannot fully abstract a value of variadic function type
'@Sendable (A, repeat each B) async -> C'
because different contexts will not be able to reliably agree on a
calling convention; try wrapping it in a struct
Which is the first I've seen of that.
Anyone have any advice?