effekt-lang / effekt

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

Effects need to be fully known #663

Open omentic opened 2 days ago

omentic commented 2 days ago

I have hit the second half of the issue in #661 again (and figured I'd open a second issue since it was very unrelated to the original issue). This commented-out code fails to compile: https://gist.github.com/omentic/58b553920b4c8402b04c2873901291df#file-iter-scala-L464

It produces a very long "failed to typecheck overload" error, but it seems like the core issue is

Possible overload: iter::take of type [T](Int){() => Unit / { Yield[T] }} => Unit / { Yield[T] }
  Effects need to be fully known: Yield[T]

I suppose this is probably another case needing a heuristic?

b-studios commented 2 days ago

Yes that's right. At take it is not possible to know which effect to handle.

While you probably mean Int, in general it could be anything.

You can always annotate the type argument to work around it: take[Int] { ... }.

omentic commented 1 day ago

Ah - thanks a bunch! :smiley:

[effekt]$ java -jar bin/effekt examples/iter.effekt 
hello!
Cons(3, Cons(2, Cons(1, Cons(1, Cons(0, Nil())))))
Cons(144, Cons(34, Cons(8, Cons(2, Cons(0, Nil())))))
b-studios commented 1 day ago

Since you work on streams you might be interested in #527. Maybe you have some insights that you would like to share?