-
Notifications
You must be signed in to change notification settings - Fork 38
Add variant of loop
/ Control
with a return value
#985
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
base: master
Are you sure you want to change the base?
Conversation
The question is whether |
FWIW, something relevant I tend to use somewhat often in my code is: effect breakWith[A](value: A): Nothing
def boundary[A] { body: => A / breakWith[A] }: A =
try body() with breakWith[A] { a => a }
def boundaryDefault[A] { body: => Unit / breakWith[A] } { default: => A } : A =
try { body(); default() } with breakWith[A] { a => a } The problem is that the semantics of A feature that could help accommodate all is "grouping" capabilities together with sub-effecting: effect Control[A] = { breakAt[A], break, continue }
def loop { body: {Control[A]} => Unit }: A // here we'd have "one" capability only to take care of
// but
def boundary { body: => A / breakAt[A] }: A |
Surprisingly, it seems to (see |
Yes, another alternative (since we only use
|
(Mostly, I just wrote some code and missed something like this, so I tried to add it to stdlib directly.) |
@jiribenes Yes, I don't know what is the best solution generally for a |
Does this work (passing this kind of capability explicitly)? How could we even construct it? |
We discussed this before in #404 |
The CI failure is weird. |
I restarted the job since it might be flaky. |
This adds a variant of
loop
with a return value.Interestingly, overload resultion is able to resolve this, even when we do not use break. 🤔