Why this fires¶
handle <expr> with h requires h to be a handler value — something whose type is handler<...>. If h resolves to anything else, there's no arm set to dispatch the performed operations to.
effect Fs { fn read(p: str) -> str }
fn run() with Fs -> str {
return perform Fs::read("x")
}
let not_a_handler = 42
fn main() {
let _ = handle run() with not_a_handler
// ^^^^^^^^^^^^ error[TE814]: `handle expr with h` requires
// `h: handler<...>`, got `int`
}Fix it¶
Pass an actual handler value:
let h = handler {
Fs::read(_p) => "stub",
}
fn main() {
let _ = handle run() with h // ok
}See also¶
TE807— a handler value that only partially covers an effect.- /docs/algebraic-effects — handler values (
let h = handler { ... }).