bynk.given.fn_unsupported
Error A given clause on a method, on a function that does not return Effect[T], or naming Events.
Only a free function in a context that returns Effect[T] may declare given. A capability operation is an effect, so a function that reaches one has to say so in its return type, and a method has no place to carry the capabilities. Events is refused too: Events.emit buffers until its handler commits, so emit in the handler, or pass the event back to the caller. Return Effect[T] and make it a free function, or take the operation as a function-value parameter. A given in a commons is bynk.given.fn_outside_context.
Example
fn size(sku: String) -> Int given Logger { // ✗ it must return an `Effect` 3}
fn size(sku: String) -> Effect[Int] given Logger { // ✓ Effect.pure(3)}In the Book
See also
- The grammar rule it governs:
given_clause. - Every code in its category, Given capabilities, on the diagnostic index.
bynk explain bynk.given.fn_unsupportedshows the same from the installed toolchain, without a network.