aboutsummaryrefslogtreecommitdiff
path: root/examples/29-effect-handler-pop/src/HelloWorld.shed
blob: 2b9491d710e5d2b01c5069ed0eff17647e92cddd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
effect Writer {
    fun hello() -> Unit;
    fun world() -> Unit;
}

pub fun main() ! Io -> Unit {
    try {
        Writer.hello!();
        print!(", ");
    } handle Writer {
        fun hello() {
            print!("hello");
            resume;
        }

        fun world() {
            print!("world");
            resume;
        }
    }

    try {
        Writer.world!();
        print!("\n");
    } handle Writer {
        fun hello() {
            print!("hello");
            resume;
        }

        fun world() {
            print!("world");
            resume;
        }
    }
}