aboutsummaryrefslogtreecommitdiff
path: root/examples/26-effect-in-handler/src
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2023-12-02 21:24:23 +0000
committerMichael Williamson <mike@zwobble.org>2023-12-02 21:26:19 +0000
commit41fcbdb71e6603919f0b751998452a45b8d9a0a3 (patch)
tree81bc8abd48f21655780f58cd395b2eb783322540 /examples/26-effect-in-handler/src
parent496e7f4addb7866fb1e419a98c52a870393296f4 (diff)
Support effects in effect handler methods
Diffstat (limited to 'examples/26-effect-in-handler/src')
-rw-r--r--examples/26-effect-in-handler/src/Example.shed44
1 files changed, 44 insertions, 0 deletions
diff --git a/examples/26-effect-in-handler/src/Example.shed b/examples/26-effect-in-handler/src/Example.shed
new file mode 100644
index 00000000..568d9ea8
--- /dev/null
+++ b/examples/26-effect-in-handler/src/Example.shed
@@ -0,0 +1,44 @@
+effect A {
+ fun a() -> Unit;
+}
+
+effect B {
+ fun b() -> Unit;
+}
+
+pub fun main() ! Io -> Unit {
+ try {
+ A.a!();
+
+ try {
+ A.a!();
+
+ try {
+ B.b!();
+ } handle B {
+ fun b() {
+ print!("b start\n");
+ A.a!();
+ print!("b end\n");
+ resume;
+ }
+ }
+
+ A.a!();
+ } handle A {
+ fun a() {
+ print!("a inner start\n");
+ A.a!();
+ print!("a inner end\n");
+ resume;
+ }
+ }
+
+ A.a!();
+ } handle A {
+ fun a() {
+ print!("a outer\n");
+ resume;
+ }
+ }
+}