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

Implement can Effect syntax for annotating effects #169

Open
jfecher opened this issue Dec 8, 2023 · 1 comment
Open

Implement can Effect syntax for annotating effects #169

jfecher opened this issue Dec 8, 2023 · 1 comment
Labels
good first issue An issue that doesn't require deep knowledge of the compiler to fix or implement language feature A feature proposal for something added to the core language (not the standard library)

Comments

@jfecher
Copy link
Owner

jfecher commented Dec 8, 2023

The effects3 branch is currently under development for implementing effects in ante's backend. It is expected that the type system component of effects is already complete but a crucial part is missing - the ability to annotate the expected effects a function has.

A function should be able to specify its effects via a new can keyword:

foo (x: I32) : I32 can Effect1, Effect2 =
    effect1 x
    effect2 x

If a function's return type is inferred, the function's effects are also inferred:

foo (x: I32) =
    effect1 x
    effect2 x

If a function's return type is specified but no effects are specified, we should assume the function is meant to be pure rather than inferring the effects:

foo (x: I32) : I32 =
    // Error: effect Effect1 is unhandled
    effect1 x
    // Error: effect Effect2 is unhandled
    effect2 x
@jfecher jfecher added language feature A feature proposal for something added to the core language (not the standard library) good first issue An issue that doesn't require deep knowledge of the compiler to fix or implement labels Dec 8, 2023
@jfecher
Copy link
Owner Author

jfecher commented Dec 24, 2023

Parsing for this issue has been implemented by #175. Next up is integration into name resolution and type checking for these annotations. E.g. name resolution should ensure the effects are declared names, and type inference can check this set against the inferred set to issue an error if the inferred set is not a subset of the declared set.

Open question: Should ante issue a warning during type inference if the inferred effect set is a subset of the declared set instead of equal to it? My current thinking is that this would discourage use of effect aliases like IO which contain several effects in them that may be unused.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue An issue that doesn't require deep knowledge of the compiler to fix or implement language feature A feature proposal for something added to the core language (not the standard library)
Projects
None yet
Development

No branches or pull requests

1 participant