-
Notifications
You must be signed in to change notification settings - Fork 59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Inference issue with nested async boundaries #804
Comments
I believe the issue is caused by The fix is to derive the boundary within the function where the type already contains the expected value. The only issue is that the function must now be inline def timeout[E, A: Flat, Ctx](after: Duration)(v: => A < (Abort[E] & Async & Ctx))(
using frame: Frame
): A < (Abort[E | Timeout] & Async & Ctx) =
if !after.isFinite then v
else
summon[Boundary[Ctx, Async & Abort[E | Timeout]]] { (trace, context) =>
Clock.use { clock =>
IO.Unsafe {
val sleepFiber = clock.unsafe.sleep(after)
val task = IOTask[Ctx, E | Timeout, A](v, trace, context)
sleepFiber.onComplete(_ => discard(task.complete(Result.fail(Timeout(frame)))))
task.onComplete(_ => discard(sleepFiber.interrupt()))
Async.get(task)
}
}
}
end timeout |
/bounty $75 for a fix that doesn't require inlining the full body of each function |
💎 $75 bounty • KyoSteps to solve:
Thank you for contributing to getkyo/kyo! |
This PR applies the workaround identified by @hearnadam with an `inline` indirection. I think we should still keep #804 open to explore a more proper solution. Users might need to define methods with boundaries and the workaround can be confusing.
The inference of
Boundary
when two operations are directly nested likeAsync.run(Async.timeout(1.second)(v))
is failing to compile. Background: #797 (comment)The text was updated successfully, but these errors were encountered: