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

Overrides do not work when changing the effect type #602

Open
TimWhiting opened this issue Oct 24, 2024 Discussed in #600 · 1 comment
Open

Overrides do not work when changing the effect type #602

TimWhiting opened this issue Oct 24, 2024 Discussed in #600 · 1 comment

Comments

@TimWhiting
Copy link
Collaborator

Discussed in #600

Originally posted by chtenb October 24, 2024

pub effect yield<a>
  ctl yield(elem : a) : ()
  
pub fun map(it : () -> <yield<a>|e> (), f : a -> b) : <yield<b>|e> ()
  with override ctl yield(elem)
    yield(f(elem))
    resume(())
  it()

This does not work

repro.kk(6, 3): type error: abstract types do not match
  context        :   with override ctl yield(elem)
                       yield(f(elem))
                       resume(())
  term           :   with override ctl yield(elem)
                       yield(f(elem))
                       resume(())
  inferred effect: <yield<$a>,yield<$a>|_e1>
  expected effect: <yield<$a>,yield<$b>|_e>
  hint           : an higher-rank type escapes its scope?

If we replace the type b with a, it does work.
I'm unsure why the inferred effect is <yield<$a>,yield<$a>|_e1>, because clearly the result of f is b.
Why does this fail, and how can we make it work?

@TimWhiting
Copy link
Collaborator Author

Using the desugaring directly doesn't work either.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant