Skip to content
Playground(another site)

bynk.context.opaque_inspection

Error An opaquely-exported type was inspected from outside its context.

A context that writes exports opaque { T } lets other contexts hold a T, pass it on and call its methods, but not look inside it: they cannot match on it, read a field, match a record pattern against it, or name one of its variants. Only the owning context sees the shape, so it can change the representation, or keep an invariant the type's constructors enforce, without breaking a consumer. Ask the owner for what you need instead: a service that returns the answer as a plain value, such as a Bool. If the shape is meant to be public, the owner exports it with exports transparent { T }.

Example

pay.bynk
context pay
exports opaque { Status } // the owner hides the shape
type Status = | Paid | Declined
// shop.bynk
context shop
consumes pay
service checkout {
on call() -> Effect[Bool] by Caller {
let s <- pay.charge(1)
match s { // ✗ `Status` is opaque here, so its variants are hidden
Paid => Effect.pure(true)
Declined => Effect.pure(false)
}
}
}
// pay.bynk
exports transparent { Status } // ✓ the owner shares the shape

In the Book

See also

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