Skip to content
Playground(another site)

bynk.context.external_construction

Error A context-owned type was constructed from outside that context.

A context that consumes another may hold and pass on the other's types, but may not build one. A refined or opaque type can promise an invariant, a Matches pattern or a smart constructor, and that holds only if every value is made by the owner; .of, .unsafe and a variant constructor are refused from outside, as is the record syntax of an opaque type. Ask the owner for the value instead: a service that returns it, or takes the plain input and does the check. bynk.context.opaque_inspection is the other side, looking inside such a value.

Example

payment.bynk
context payment
exports transparent { AuthId }
type AuthId = String where Matches("AUTH-[0-9]+")
service issue {
on call() -> Effect[AuthId] by Caller { … }
}
// orders.bynk
context orders
consumes payment
AuthId.of(s) // ✗ only `payment` makes an `AuthId`
payment.issue() // ✓ ask `payment` for one

In the Book

See also

  • Every code in its category, Contexts, on the diagnostic index.
  • bynk explain bynk.context.external_construction shows the same from the installed toolchain, without a network.