aboutsummaryrefslogtreecommitdiff
path: root/examples/33-effect-break/src/HelloWorld.shed
blob: f836ab58be4cdf0a5914cd599dc8c60d3a412ac4 (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
effect Writer {
    fun hello() -> Unit;
    fun world() -> Unit;
}

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

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

    print!("\n");
}