diff options
Diffstat (limited to 'examples/24-effect-with-state/src/HelloWorld.shed')
| -rw-r--r-- | examples/24-effect-with-state/src/HelloWorld.shed | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/examples/24-effect-with-state/src/HelloWorld.shed b/examples/24-effect-with-state/src/HelloWorld.shed new file mode 100644 index 00000000..50d64428 --- /dev/null +++ b/examples/24-effect-with-state/src/HelloWorld.shed @@ -0,0 +1,22 @@ +effect StringBuilder { + fun append(String) -> Unit; +} + +pub fun main() ! Io -> Unit { + var result = ""; + + try { + StringBuilder.append!("hello"); + StringBuilder.append!(", "); + StringBuilder.append!("world"); + StringBuilder.append!("\n"); + } handle StringBuilder { + fun append(value) { + assign result = result + value; + + resume; + } + } + + print!(result); +} |
