effekt-lang / effekt-lang/effekt

Type annotations for patterns

Open
#1,308 2 comments 1 reaction 1 assignee Claimed by @martin-ilgner View on GitHub
area:parser/lexer area:patternmatching area:typer
Dominant language
Scala
Stars
469
Forks
41
Avg merge
1d 16h
Merged PRs (30d)
23

Description

Currently, we can't write the `: Int` part of
```scala
expr match {
case Cons(x: Int, _) => x // doesn't parse, "Expected ) but got :"
...
}
```

similarly, we can't use it in `if (expr is Some(x: String))` and `val Some(b: Bool) = expr`.

This is especially annoying for tuple parameters
```scala
// argument list works
def f { g: (Int, String) => Unit }: Unit = g(0, "")
f { (x: Int, y) => () } // works (and reports an error if the annotation is wrong)

// tuple does not
def f { g: ((Int, String)) => Unit }: Unit = g((0, ""))
f { case (x: Int, y) => () } // doesn't parse, "Expected ) but got :"
```

However, I do **not** want to use it for runtime matching like in Scala:
```scala
// not this, please
expr match {
case n: Int => ...
case s: String => ...
case _ => panic("ohno")
}
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.