Yeah… as it’s written it would require higher-kinded types. Since we know that function uses the For handler though, it could be re-written as something like this maybe:
fn eff_iter<T, F>(f: F) -> EffIterator<impl Generator<Yield = T, Resume = (), Return = ()>>
where F: FnOnce(),
F effect Iter<T>=For
I’m not quite sure what you’re saying here. All functions that could potentially do Io would need to be (potentially) compiled twice. Or rather, they’re secretly a generic function which can be compiled with different Io type parameters. If we know they don’t actually do any Io then they could be compiled just once and monomorphisation would turn my_func<Io=Native> and my_func<Io=Async> into the same function. If they call any function that may need to do Io though then they’ll need to be compiled into a state machine when built with Io=Async.
Virtual dispatch also requires dynamic memory allocation. In the RFC I’ve half-written, using virtual dispatch is a compilation error unless you explicitly opt-in to giving your generator a heap-allocated stack.
Is there any potential that interpreting a presently correct synchronous function as asynchronous could break it?
Well we can’t possibly make the Io effect capture all potential kinds of blocking, so there’ll be some libraries that will lock up your event loop if used in an async context. That’s no worse than the status-quo though. Or did you mean something else?