diff options
| author | Michael Williamson <mike@zwobble.org> | 2024-03-02 15:39:21 +0000 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2024-03-02 15:39:21 +0000 |
| commit | 925916777a52ffa2f0cf94c761b3a4616fe17019 (patch) | |
| tree | 02f01edaf11c6947d4036de4ebf1c8f2292e3957 /examples | |
| parent | f1089538f04062f71f530fa27396f6f446a0fc47 (diff) | |
Add example for generic effects
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/33-generic-effects/shed.toml | 7 | ||||
| -rw-r--r-- | examples/33-generic-effects/src/HelloWorld.shed | 11 |
2 files changed, 18 insertions, 0 deletions
diff --git a/examples/33-generic-effects/shed.toml b/examples/33-generic-effects/shed.toml new file mode 100644 index 00000000..04d4475a --- /dev/null +++ b/examples/33-generic-effects/shed.toml @@ -0,0 +1,7 @@ +[[shed.bins]] +name = "hello-world" +main-namespace = "HelloWorld" + +[[shed.examples]] +bin = "hello-world" +expected-output = "hello\nhello" diff --git a/examples/33-generic-effects/src/HelloWorld.shed b/examples/33-generic-effects/src/HelloWorld.shed new file mode 100644 index 00000000..a54803c6 --- /dev/null +++ b/examples/33-generic-effects/src/HelloWorld.shed @@ -0,0 +1,11 @@ +pub fun main() ! Io -> Unit { + twice!(fn () ! Io { + print!("hello\n") + }); +} + +fun twice[!E](f: fn () ! E -> Unit) ! E -> Unit { + f!(); + f!(); +} + |
