effekt-lang / effekt-lang/effekt
Singleton interfaces
- Dominant language
- Scala
- Stars
- 469
- Forks
- 41
- Avg merge
- 1d 16h
- Merged PRs (30d)
- 23
Description
We have records that desugar to data types with a single constructor.
```
record Stuff[A](x: A)
type Stuff[A] {
Stuff(x: A)
}
```
Dually, we could have operations that desugar to an interface with a single method.
```
operation Work[A](): A
interface Work {
def Work[A](): A
}
```
These are essentially nominally typed functions.
However, as the above example reveals it is not clear where type parameters should be put.
One idea would be to mirror what happens with data types
```
interface Work[A] {
def Work(): A
}
```
They should be used on the term level as follows:
```
def myWork = new Work[Int] { () => 0 }
myWork()
```
The following should not be ok:
```
def myWork = new Work[Int] { () => 0 }
myWork.Work()
```
Singleton effect operations should work as before except that it is harder to define `Fail` and `Raise` with universally quantified result type.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.