aboutsummaryrefslogtreecommitdiff
path: root/examples/30-effect-in-handler
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2025-01-12 15:11:04 +0000
committerMichael Williamson <mike@zwobble.org>2025-01-12 15:11:04 +0000
commit027d73dea19c4154d27c77cd82dd4b28649cdf3f (patch)
treec5ef4e7e2d7bc096389c55507bae87793906a862 /examples/30-effect-in-handler
parent57de5c166aeab88d0da164171520e962519bc999 (diff)
Support recursive project dependencies
Diffstat (limited to 'examples/30-effect-in-handler')
-rw-r--r--examples/30-effect-in-handler/shed-examples.json59
-rw-r--r--examples/30-effect-in-handler/shed.json58
-rw-r--r--examples/30-effect-in-handler/src/Example.shed44
3 files changed, 61 insertions, 0 deletions
diff --git a/examples/30-effect-in-handler/shed-examples.json5 b/examples/30-effect-in-handler/shed-examples.json5
new file mode 100644
index 00000000..0717d99b
--- /dev/null
+++ b/examples/30-effect-in-handler/shed-examples.json5
@@ -0,0 +1,9 @@
+{
+ examples: [
+ {
+ project: ".",
+ bin: "example",
+ expectedOutput: "a outer\na inner start\na outer\na inner end\nb start\na inner start\na outer\na inner end\nb end\na inner start\na outer\na inner end\na outer",
+ },
+ ],
+}
diff --git a/examples/30-effect-in-handler/shed.json5 b/examples/30-effect-in-handler/shed.json5
new file mode 100644
index 00000000..e642a813
--- /dev/null
+++ b/examples/30-effect-in-handler/shed.json5
@@ -0,0 +1,8 @@
+{
+ bins: [
+ {
+ name: "example",
+ mainNamespace: "Example",
+ },
+ ],
+}
diff --git a/examples/30-effect-in-handler/src/Example.shed b/examples/30-effect-in-handler/src/Example.shed
new file mode 100644
index 00000000..568d9ea8
--- /dev/null
+++ b/examples/30-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;
+ }
+ }
+}