aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2023-12-03 18:13:30 +0000
committerMichael Williamson <mike@zwobble.org>2023-12-03 18:13:30 +0000
commit8decaba8f75d16550d5f0e6caf9ddaff18dad38a (patch)
tree281c39b4933542b69c6189f087d472dfb76bb918 /examples
parent0bcd3fbadef087b2b3ed6e4f398f6e6c36f11209 (diff)
Support exception handler method break
Diffstat (limited to 'examples')
-rw-r--r--examples/27-effect-break/shed.toml7
-rw-r--r--examples/27-effect-break/src/HelloWorld.shed27
2 files changed, 34 insertions, 0 deletions
diff --git a/examples/27-effect-break/shed.toml b/examples/27-effect-break/shed.toml
new file mode 100644
index 00000000..bf5c13c4
--- /dev/null
+++ b/examples/27-effect-break/shed.toml
@@ -0,0 +1,7 @@
+[[shed.bins]]
+name = "hello-world"
+main-namespace = "HelloWorld"
+
+[[shed.examples]]
+bin = "hello-world"
+expected-output = "hello, world"
diff --git a/examples/27-effect-break/src/HelloWorld.shed b/examples/27-effect-break/src/HelloWorld.shed
new file mode 100644
index 00000000..f836ab58
--- /dev/null
+++ b/examples/27-effect-break/src/HelloWorld.shed
@@ -0,0 +1,27 @@
+effect Writer {
+ fun hello() -> Unit;
+ fun world() -> Unit;
+}
+
+pub fun main() ! Io -> Unit {
+ try {
+ Writer.hello!();
+ print!(", ");
+ Writer.world!();
+ Writer.hello!();
+ print!(", ");
+ Writer.world!();
+ } handle Writer {
+ fun hello() {
+ print!("hello");
+ resume;
+ }
+
+ fun world() {
+ print!("world");
+ break;
+ }
+ }
+
+ print!("\n");
+}