import std/list // `multi ctl` operations (ADR 0017): the clause's `resume` may be called // several times; it is typed like a `ctl` clause's. effect amb { multi ctl choose :: -> Bool final ctl fail :: -> Never } pub fn all :: action: fn() -> a / -> List / { handle { [action ()] } with { choose -> list.append (resume True) (resume False), fail -> [] } } //~^^^^^^ TYPE all: fn(fn() -> a / ) -> List / pub fn bits :: -> List<(Bool, Bool)> { all fn { (choose (), choose ()) } } // `resume` takes the operation's result. pub fn wrong :: -> List { handle { [if choose () { 1 } else { 2 }] } with { choose -> resume 1 //~ ERROR E0202 , fail -> [] } } // A `final ctl` clause has no `resume`. pub fn no_resume :: -> List { handle { [if choose () { 1 } else { 2 }] } with { choose -> resume True , fail -> resume True //~ ERROR E0101 resume } }