Skip to content

Commit

Permalink
Change example of typeparameteric.effekt
Browse files Browse the repository at this point in the history
  • Loading branch information
b-studios committed Jan 20, 2024
1 parent f7b0250 commit 517dd25
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
1 change: 0 additions & 1 deletion effekt/shared/src/main/scala/effekt/Typer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,6 @@ object Typer extends Phase[NameResolved, Typechecked] {
// resume(v)
FunctionType(Nil, Nil, List(tpe), Nil, ret, Effects.Pure)
}

Context.bind(Context.symbolOf(resume).asBlockSymbol, resumeType, continuationCapt)

body checkAgainst ret
Expand Down
21 changes: 16 additions & 5 deletions examples/pos/bidirectional/typeparametric.effekt
Original file line number Diff line number Diff line change
@@ -1,13 +1,24 @@
extern interface Cap[U, V]

// purposefully not pure to trigger a bug
extern io def cap[U, V](): Cap[U, V] at {} = "42"

interface Foo[S] {
def op[A]() {f: Cap[S, A]}: Cap[S, A] at {} / { Exception[A] }
def op[A]() {f: Cap[S, A]}: Cap[S, A] at {f} / { Exception[S] }
}

def main() =
try { () } with Foo[Int] {
def op[B]() = {
val k = resume;
def main() = {
// Here hides a bug with the capture set inference. Try changing `val` to `def`
// and observe a type error ("not allowed {io}")
val myCap = cap[Int, String]()
try {
report[Int] {
val res: Cap[Int, String] at {} = do op() { myCap };
()
}
} with Foo[Int] {
def op[B]() = {
resume { {g: Cap[Int, B]} => do raise(42, "") }
}
}
}

0 comments on commit 517dd25

Please sign in to comment.