effekt-lang / effekt-lang/effekt
Nicer error messages on a likely forgotten resume
- Dominant language
- Scala
- Stars
- 469
- Forks
- 41
- Avg merge
- 1d 16h
- Merged PRs (30d)
- 23
Description
Students (and many other users like me) often forget to `resume` from a handler.
We could customise the error message, especially when it's obvious from the type that using `resume` would fix the type error one gets.
Let's take a look at a small example:
```scala
effect get(): Int
def foo() =
try { println(do get()) }
with get {
42
// ^^
// Expected Unit but got Int.
}
```
We could customise ( 🚲🏠 ) the error to something slightly more specific like:
```
Expected Unit but got Int.
Did you mean to use `resume: Int => Unit` in the handler in order to resume?
```
The heuristic is pretty straightforward: an additional hint should fire if in the handler we get "expected `τ1` but got `τ2`" _and_ `resume` has type `τ2 => τ1`.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.