Skip to content
TE813 · Effects · error

Cannot infer a type argument for an effect operation

A generic effect's type parameter couldn't be resolved at a `perform` site — neither the argument types nor a `with Effect<Concrete>` pin gave it a concrete type.

Why this fires

A generic effect's type parameter couldn't be resolved at a perform site. When an effect declares a type parameter (effect State<T> { fn get() -> T ... }), Zolo infers T from the argument types at the perform call, or from a with State<ConcreteType> pin on the enclosing function — but if neither gives it a concrete type, the operation is genuinely ambiguous.

effect State<T> {
    fn get() -> T
    fn set(v: T)
}

fn run() with State {
    let _ = perform State::get()
    //              ^^^^^^^^^^^^ error[TE813]: cannot infer type argument `T` for
    //                           `State<T>`; annotate explicitly (e.g.
    //                           `perform State<T>::get(...)` or annotate the
    //                           surrounding expression's type)
}

State::get() takes no arguments to unify T against, and the enclosing with State doesn't pin a concrete type either.

Fix it

1. Pin the type in the with clause

fn run() with State<int> -> int {
    return perform State::get()   // ok — T = int from the with-clause pin
}

2. Let an argument fix it

fn run() with State {
    perform State::set(99)        // ok — T = int, unified from the argument
}

See also

See also

Search Zolo

9 results

en