aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2023-11-19 15:53:19 +0000
committerMichael Williamson <mike@zwobble.org>2023-11-19 15:53:19 +0000
commitbdf23a95c53971323a6909474bdc34268eac6121 (patch)
tree77e6b709c0aa248dab885710afe5e8b75b530c6a /examples
parent7ee5eaa46524eb4e6b46487f7bb138c4f9dca836 (diff)
Add example for resume with value
Diffstat (limited to 'examples')
-rw-r--r--examples/22-effect-resume-with-value/shed.toml7
-rw-r--r--examples/22-effect-resume-with-value/src/HelloWorld.shed21
2 files changed, 28 insertions, 0 deletions
diff --git a/examples/22-effect-resume-with-value/shed.toml b/examples/22-effect-resume-with-value/shed.toml
new file mode 100644
index 00000000..bf5c13c4
--- /dev/null
+++ b/examples/22-effect-resume-with-value/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/22-effect-resume-with-value/src/HelloWorld.shed b/examples/22-effect-resume-with-value/src/HelloWorld.shed
new file mode 100644
index 00000000..3252aaf3
--- /dev/null
+++ b/examples/22-effect-resume-with-value/src/HelloWorld.shed
@@ -0,0 +1,21 @@
+effect Messages {
+ fun hello() -> String;
+ fun world() -> String;
+}
+
+pub fun main() ! Io -> Unit {
+ try {
+ print!(Messages.hello!());
+ print!(", ");
+ print!(Messages.world!());
+ print!("\n");
+ } handle Messages {
+ fun hello() {
+ resume "hello";
+ }
+
+ fun world() {
+ resume "world";
+ }
+ }
+}