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

Suggestion: Generalize type variables in mask behind #519

Open
anfelor opened this issue May 13, 2024 · 1 comment
Open

Suggestion: Generalize type variables in mask behind #519

anfelor opened this issue May 13, 2024 · 1 comment

Comments

@anfelor
Copy link
Collaborator

anfelor commented May 13, 2024

In Koka, we can use mask behind to override a handler as such:

effect eff<a>
  ctl op() : ()

fun test(comp : () -> <eff<a>|e> ()) : <eff<a>|e> ()
  with ctl op() -> {op(); resume(())}
  with mask behind<eff>
  comp()

However, this currently only allows us to override an effect with exactly the same effect, including type variables. Thus, we can not write: fun test(comp : () -> <eff<a>|e> ()) : <eff<b>|e> () (notice the b in the last effect row).

Is there anything stopping us from allowing a different type variable on the masked effect? Concretely, I am suggesting to change the type signature of mask behind from:

mask behind<eff> : forall<a,b,e> () -> ((() -> <eff<a>|e> b) -> <eff<a>,eff<a>|e> b)

to:

mask behind<eff> : forall<a,a1,b,e> () -> ((() -> <eff<a>|e> b) -> <eff<a>,eff<a1>|e> b)

where all type variables in the masked effect are now generalized (as a1 here). @jasigal has a larger example where this functionality would be useful.

@jasigal
Copy link

jasigal commented May 13, 2024

In general, I find this useful when there's a purely local need to handle an effect using a different version of it, meaning named handlers aren't really needed.

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

3 participants