The compiler will complain about ambiguous function calls if I provide @Sendable function composition and the non-sendable version at the same time.
Do I really have to provide the compose function with difference names, e.g. sendableCompose, unsendableCompose?
@Sendable
public func compose <each A, B, C>(
_ g: @escaping @Sendable (B) -> C,
_ f: @escaping @Sendable (repeat each A) -> B
) -> (repeat each A) -> C {
{ (args: repeat each A) in
g(f(repeat each args))
}
}
public func compose <each A, B, C>(
_ g: @escaping (B) -> C,
_ f: @escaping (repeat each A) -> B
) -> (repeat each A) -> C {
{ (args: repeat each A) in
g(f(repeat each args))
}
}
public func compose <each A, B, C>(
_ g: @escaping @Sendable (B) -> C,
_ f: @escaping @Sendable (repeat each A) -> B
) -> @Sendable (repeat each A) -> C {
{ (args: repeat each A) in
g(f(repeat each args))
}
}
public func compose <each A, B, C>(
_ g: @escaping (B) -> C,
_ f: @escaping (repeat each A) -> B
) -> (repeat each A) -> C {
{ (args: repeat each A) in
g(f(repeat each args))
}
}
The leading @Sendable is unnecessary in Swift 6.0 (see SE-0418 )