-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change example of typeparameteric.effekt
- Loading branch information
Showing
2 changed files
with
16 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, "") } | ||
} | ||
} | ||
} |