Skip to content
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

Resume both bidirectional and normal handlers with both either a block or a value #686

Open
phischu opened this issue Nov 12, 2024 · 2 comments
Labels
feature New feature or request requires-design

Comments

@phischu
Copy link
Collaborator

phischu commented Nov 12, 2024

Consider the following program which works fine in Effekt:

effect stop(): Unit

effect yield(): Unit / stop

def main() = {
  try {
    do yield()
  } with stop {
    resume(())
  } with yield {
    resume { () }
  }
}

Indeed, stop is a normal effect and we resume it with resume(()), and yield is a bidirectional effect and we resume it with resume { () }.

I would like the following program to be accepted too and be the same as the previous one:

effect stop(): Unit

effect yield(): Unit / stop

def main() = {
  try {
    do yield()
  } with stop {
    resume { () }
  } with yield {
    resume(())
  }
}

We should be able to resume both kinds of effects with both kinds of syntax. resume(v) should be syntactic sugar for resume { v }.

@phischu phischu added the feature New feature or request label Nov 12, 2024
@b-studios
Copy link
Collaborator

b-studios commented Nov 12, 2024

Quick question: what do we do in the following case?

val k = box resume

a. nothing: just forbid it; users should eta-expand
b. eta-expand: but to what? the bidirectional one because it is more general?

By now I strongly tend towards a. This simplifies the implementation and will help us provide better error messages at the cost of a few eta expansions (that might even make it clearer...)

@b-studios
Copy link
Collaborator

Requiring eta expansion destroys demos, since we cannot simply write resume unless we already know it.

One solution would be to have a better type on hover on the operation that mentions the type of resume. Another option would be to error in Typer and provide some better feedback to the user that tries to call resume.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request requires-design
Projects
None yet
Development

No branches or pull requests

3 participants