diff options
| author | Michael Williamson <mike@zwobble.org> | 2023-11-19 15:49:48 +0000 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2023-11-19 15:49:48 +0000 |
| commit | 7ee5eaa46524eb4e6b46487f7bb138c4f9dca836 (patch) | |
| tree | 6867ed186a7850d0c2291de84711b777f328485f /examples | |
| parent | b99b938b2f33e4d12d63629f3d80e987c31d1892 (diff) | |
Add example for resuming effects
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/21-effect-resume/shed.toml | 7 | ||||
| -rw-r--r-- | examples/21-effect-resume/src/HelloWorld.shed | 23 |
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; + } + } +} |
