Comment by Trung0246

10 hours ago

For some funsie here's my fully working delimited continuation in C with effect handler example: https://godbolt.org/z/3ehehvo6E

No ASM involved so technically portable (although it depends on built-in).

Flix equivalent (copy paste to https://play.flix.dev/):

    eff Pick {
        def pick(): Int32
    }

    def body(): (Int32, Int32, Int32) \ Pick = {
        let a = Pick.pick();
        let b = Pick.pick();
        let c = Pick.pick();
        (a, b, c)
    }

    def handlePick(f: Unit -> a \ ef): List[a] \ ef - Pick =
        run {
            f() :: Nil
        } with handler Pick {
            def pick(_, resume) =
                resume(1) ::: resume(2) ::: resume(3)
        }

    def main(): Unit \ IO =
        println(handlePick(body))