Skip to content
Playground(another site)

bynk.agent.return_not_effect

Error An agent handler's return type is not an Effect.

An agent handler reads and writes the agent's stored state, and may call other agents and capabilities, so it does work in the world, not just compute a value. Bynk marks that in the type: a handler must return Effect[T], and its caller takes the result with <-. A bare Int would claim the handler is pure. Wrap the return type in Effect. A plain fn, which really is pure, returns an ordinary value.

Example

on call get() -> Int { // ✗ a handler that reads state is an effect
n
}
on call get() -> Effect[Int] { // ✓
n
}

In the Book

See also

  • The grammar rule it governs: agent_decl.
  • Every code in its category, Agents, on the diagnostic index.
  • bynk explain bynk.agent.return_not_effect shows the same from the installed toolchain, without a network.