facebook / facebook/hhvm

Introduce [pure] as coeffects bottom type

Open
#8,828 0 comments 0 reactions 0 assignees View on GitHub
feature request hack
Dominant language
C++
Stars
18.7k
Forks
3.1k
Avg merge
1h 47m
Merged PRs (30d)
2

Description

The current coeffects system allows you to describe a pure function by using the empty set `[]` annotation:

```hack
function someFunc(int $x)[] {
return $x + 1;
}
```

While this makes sense given the system described, it's easy to miss when scanning code:

```
function someFunc(int $x)[] { // no effects allowed
vs
function someFunc(int $x) { // all effects allowed
```

What if you instead required an explicit pure keyword:

```hack
function someFunc(int $x)[pure] {
return $x + 1;
}
```

It would be the bottom type of the system, so `[pure, io]` would be treated as `[io]` (and would presumably also be flagged by the typechecker).

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.