aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-rw-r--r--examples/21-effect-resume/shed.toml7
-rw-r--r--examples/21-effect-resume/src/HelloWorld.shed23
2 files changed, 30 insertions, 0 deletions
diff --git a/examples/21-effect-resume/shed.toml b/examples/21-effect-resume/shed.toml
new file mode 100644
index 00000000..bf5c13c4
--- /dev/null
+++ b/examples/21-effect-resume/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/21-effect-resume/src/HelloWorld.shed b/examples/21-effect-resume/src/HelloWorld.shed
new file mode 100644
index 00000000..a5e96e2f
--- /dev/null
+++ b/examples/21-effect-resume/src/HelloWorld.shed
@@ -0,0 +1,23 @@
+effect Writer {
+ fun hello() -> Unit;
+ fun world() -> Unit;
+}
+
+pub fun main() ! Io -> Unit {
+ try {
+ Writer.hello!();
+ print!(", ");
+ Writer.world!();
+ print!("\n");
+ } handle Writer {
+ fun hello() {
+ print!("hello");
+ resume;
+ }
+
+ fun world() {
+ print!("world");
+ resume;
+ }
+ }
+}