bynk.effect.capability_in_pure_context
Error A capability was used in a pure context.
Calling a capability operation is an effect, and effects are only allowed in a body that is itself effectful, one that returns Effect[T], so that a type tells you whether a body reaches outside. A lambda checked against a plain function type such as (Int) -> Int is a pure body, so a capability call inside it is refused even when the handler around it is effectful. Make the call in the handler, bind it with <-, and pass the result in. A call the given clause does not cover is bynk.given.undeclared_capability.
Example
let add: (Int) -> Int = (n) => { let t = Clock.now() // ✗ a capability call in a pure lambda n}
let t <- Clock.now() // ✓ the handler is effectful, so it makes the calllet add: (Int) -> Int = (n) => n + tIn the Book
See also
- Every code in its category, Effects, on the diagnostic index.
bynk explain bynk.effect.capability_in_pure_contextshows the same from the installed toolchain, without a network.