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

Term-level type annotations for effectful operations. #1197

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

dhil
Copy link
Member

@dhil dhil commented Jul 25, 2024

This patch makes it possible to annotate effectful operations at the term-level. Type annotations are crucial when operations are polymorphic. Prior to this patch, it was only possible to annotate polymorphic operations in signatures. As a consequence it was impossible to make the following kind of program type-check.

handle(do Throw) {
  case ans -> Just(ans)
  case <Throw> : (forall a. () => a) -> Nothing
}

The problem is that Links does not infer polymorphism (rightly so), so the inferred type of Throw will fail to check against the pattern type in the Throw-case. With this patch we can annotate the invocation to make the program type check.

handle(do (Throw : forall a. () => a)) {
  case ans -> Just(ans)
  case <Throw> : (forall a. () => a) -> Nothing
}

This patch makes it possible to annotate effectful operations at the
term-level. Type annotations are crucial when operations are
polymorphic. Prior to this patch, it was only possible to annotate
polymorphic operations in signatures. As a consequence it was
impossible to make the following kind of program type-check.

```links
handle(do Throw) {
  case ans -> Just(ans)
  case <Throw> : (forall a. () => a) -> Nothing
}
```

The problem is that Links does not infer polymorphism (rightly so), so
the inferred type of `Throw` will fail to check against the pattern
type in the `Throw`-case. With this patch we can annotate the invocation to make the program type check.

```links
handle(do (Throw : forall a. () => a)) {
  case ans -> Just(ans)
  case <Throw> : (forall a. () => a) -> Nothing
}
```
@dhil
Copy link
Member Author

dhil commented Jul 25, 2024

Closing and reopening to activate CI.

@dhil dhil closed this Jul 25, 2024
@dhil dhil reopened this Jul 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant