Skip to content
Playground(another site)

bynk.actor.refinement_in_sum

Error A refinement actor appears as a member of a multi-actor sum.

A refinement actor has its base's scheme and only narrows it, and peers of a sum are told apart by scheme, so it can't stand beside its base as another choice. Name the base as the peer and test the extra condition in its arm, or give the refined route its own by who: Admin.

Example

type UserId = String where NonEmpty
actor User { auth = Bearer(secret = "JWT_KEY"), identity = UserId }
actor Admin = User where hasClaim("admin")
service api from http {
on POST("/x") () -> Effect[HttpResult[String]] by who: User | Admin { // ✗ `Admin` refines `User`
service api from http {
on POST("/x") () -> Effect[HttpResult[String]] by who: Admin { // ✓ its own route

In the Book

See also

  • Every code in its category, Actors, on the diagnostic index.
  • bynk explain bynk.actor.refinement_in_sum shows the same from the installed toolchain, without a network.