aboutsummaryrefslogtreecommitdiff
path: root/examples/28-effect-with-state/src/HelloWorld.shed
blob: 00d77103c973b5e0bfc6edb6fb58ac1c6447a839 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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) {
            set result = result + value;

            resume;
        }
    }

    print!(result);
}