Structural Type

A structural type is a shape with named fields, given a name:

bondy
type Person = {name: String, age: Int & >= 0}

The name gives the type an identity. A plain map with the right keys is not a Person: you get one by constructing it, which is where the checks run.

  • Person(...) checks every field; with literals, the compiler does it at compile time.
  • construct(data, Person) checks a map from outside and returns Ok or Error with the path of each failing field.
  • Person!(...) trusts you and skips the runtime check.

A structural type can play roles directly: relation Plan = {...}, constraint Bucket = {...} and event Allowed = {...} each declare one and give it a role in one line.