How to avoid cascading async functions?

Yeah, I feel your pain here. I don't think this is a function colouring issue though: async is no more of a function colour than throws[1]. This feels more like an issue with intersection of language features, where there is some work missing to get things to glue together.

What it seems like you want is a way to make your DSL operate nicely when using both sync and async code. This is basically reasync, to go with rethrows. That's a reasonable ask! Having a way to essentially be "generic" across the async effect is a totally natural feature, and I don't think anyone on the Swift team has ruled it out. In my view, that's what's really missing here.


  1. What is frequently meant when people say "function colour" is really very close to the idea of a function effect. Swift has an effect system, but I'd argue it hasn't generalized it yet, so each new effect needs bespoke handling in several places. ↩︎

7 Likes