effekt-lang / effekt

A language with lexical effect handlers and lightweight effect polymorphism
https://effekt-lang.org
MIT License
315 stars 20 forks source link

Separators of operations are parsed inconsistently #595

Open jiribenes opened 2 days ago

jiribenes commented 2 days ago

The following program using a space to separate two operations (both in their definition and implementation) is currently syntactically valid:

interface Foo { def foo(): Int def bar(): Int }
def main() = 
  try { do foo() + do bar() }
  with Foo { def foo() = resume(42) def bar() = resume(100) }
Proof Screenshot 2024-09-17 at 17 38 42

Inserting semicolons in order to separate the two operations is not allowed: neither in their definition, nor in their implementation.


In contrast, if you write:

type Quux { Bar() Baz() }

then you actually must insert a semicolon or a newline to get a successful parse.

jiribenes commented 1 day ago

Related to https://github.com/effekt-lang/effekt/issues/287, as the following suggestion would make it a little bit more symmetric:

sequence constructors not with semicolons type B { True(); False() } but type B { case True() case False() }

jiribenes commented 1 day ago

Maybe one more reason why it feels surprising:

def helloWorld() = {
  def foo() = println("hello") def bar() = println("goodbye")
  foo(); bar()
}

does not parse here (requires a newline between the two definitions), but parses fine in the cases outlined above.