From bdf23a95c53971323a6909474bdc34268eac6121 Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Sun, 19 Nov 2023 15:53:19 +0000 Subject: Add example for resume with value --- examples/22-effect-resume-with-value/shed.toml | 7 +++++++ .../22-effect-resume-with-value/src/HelloWorld.shed | 21 +++++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 examples/22-effect-resume-with-value/shed.toml create mode 100644 examples/22-effect-resume-with-value/src/HelloWorld.shed (limited to 'examples') 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"; + } + } +} -- cgit v1.2.3