Signature families¶
Each object sort of a syntax declaration is an ordinary checked family of the module. This module
derives those families and their constructors from a signature and converts between host
Term values and family values.
families
¶
The QIEC families of a binding signature and the codec of their values.
Each object sort S of a signature Sig is one closed QIEC family,
named Sig.S (quivers.qiec.names.member_name). Its constructors are the
signature's constructors into S, under their own names, with one field
per argument in source order: an object argument is a field of its sort's
family, a data argument a field of the data sort's value type, and an index
argument an Int. An argument that binds variables is the body in the
extended scope, a de Bruijn term like any other. Every sort some argument
binds has a variable constructor Sig.S.var(index : Int), the
BoundVar(index) of quivers.structural.signature.
The families are the one family notion of a signature: computations, case
analysis, deductions, encoders, decoders, and decoder laws all use them.
At the host boundary a value of Sig.S is a structural Term, so
SignatureFamilies.value and SignatureFamilies.term convert between the
two; the conversion is the identity on the tree, so it costs the term's
size.
VARIABLE_MEMBER
module-attribute
¶
The member name of a sort's variable constructor.
SIGNATURE_PROTOCOL
module-attribute
¶
The source protocol of the standalone module of a signature's families.
SignatureFamilyError
¶
Bases: ValueError
A signature has no QIEC families, or a value does not fit them.
SignatureFamilies
didactic-model
¶
SignatureFamilies(*, signature: Signature = field(opaque=True, extras=OPAQUE_BY_VALUE), module: str)
Bases: ValueModel
The closed QIEC families of one term signature in one module.
| PARAMETER | DESCRIPTION |
|---|---|
signature
|
The signature; it must be first-order or binding, not graph shaped.
TYPE:
|
module
|
The name of the module that declares the families, which their identities derive from.
TYPE:
|
families
cached
property
¶
families: Mapping[str, FamilyDecl]
The family of every object sort, keyed by sort.
| RETURNS | DESCRIPTION |
|---|---|
Mapping of str to FamilyDecl
|
The families, in sort order. |
constructors
cached
property
¶
constructors: Mapping[str, ConstructorDecl]
Every constructor, keyed by its name in the families.
| RETURNS | DESCRIPTION |
|---|---|
Mapping of str to ConstructorDecl
|
The signature's constructors under their own names, then the
variable constructors under |
bindings
cached
property
¶
bindings: Mapping[ConstructorId, tuple[tuple[ConstructorId, ...], ...]]
For each binding constructor, the variables each field binds.
| RETURNS | DESCRIPTION |
|---|---|
Mapping
|
Per field, the variable constructor of each bound variable's sort, outermost first; an empty tuple for an unbound field. |
registry
cached
property
¶
registry: KernelRegistry
The checked registry of the families.
| RETURNS | DESCRIPTION |
|---|---|
KernelRegistry
|
The registry values of the families are checked against. |
type_of
¶
type_of(sort: str) -> TypeApplication
The QIEC type of a sort.
| PARAMETER | DESCRIPTION |
|---|---|
sort
|
An object sort.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
TypeApplication
|
Its family, applied to nothing. |
| RAISES | DESCRIPTION |
|---|---|
SignatureFamilyError
|
If the sort is not an object sort. |
Source code in src/quivers/structural/families.py
to_module
¶
to_module() -> QiecModule
The families as a standalone checked module.
| RETURNS | DESCRIPTION |
|---|---|
QiecModule
|
The families and constructors, nothing else. |
Source code in src/quivers/structural/families.py
syntax
¶
syntax(term: Term, sort: str) -> ConstructorValue
The QIEC constructor value of a structural term.
| PARAMETER | DESCRIPTION |
|---|---|
term
|
The term.
TYPE:
|
sort
|
Its sort.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
ConstructorValue
|
The same tree over the families. |
| RAISES | DESCRIPTION |
|---|---|
SignatureFamilyError
|
If the term does not fit the signature. |
Source code in src/quivers/structural/families.py
value
¶
value(term: Term, sort: str) -> RuntimeConstructor
The runtime value of a structural term, as the machine holds it.
| PARAMETER | DESCRIPTION |
|---|---|
term
|
The term.
TYPE:
|
sort
|
Its sort.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
RuntimeConstructor
|
The evaluated constructor tree. |
Source code in src/quivers/structural/families.py
term
¶
term(value: RuntimeConstructor, sort: str | None = None) -> Term
The structural term of a runtime value, checked against the families.
| PARAMETER | DESCRIPTION |
|---|---|
value
|
A value of one of the families.
TYPE:
|
sort
|
The sort the value must have; its own type's sort when omitted.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Term
|
The same tree. |
| RAISES | DESCRIPTION |
|---|---|
SignatureFamilyError
|
If a constructor does not belong to the families, a node has another sort than its position requires, or a field has the wrong kind of value. |
Source code in src/quivers/structural/families.py
479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 | |
sort_of_type
¶
sort_of_type(type_: TypeExpr) -> str | None
The sort whose family a type is, if any.
| PARAMETER | DESCRIPTION |
|---|---|
type_
|
A type.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
str or None
|
The sort, or |
Source code in src/quivers/structural/families.py
family_name
¶
The QIEC family name of a signature's sort.
| PARAMETER | DESCRIPTION |
|---|---|
signature
|
The signature's name.
TYPE:
|
sort
|
The object sort.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
str
|
|
Source code in src/quivers/structural/families.py
variable_name
¶
The variable constructor name of a signature's sort.
| PARAMETER | DESCRIPTION |
|---|---|
signature
|
The signature's name.
TYPE:
|
sort
|
The sort.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
str
|
|
Source code in src/quivers/structural/families.py
signature_families
cached
¶
signature_families(signature: Signature, module: str) -> SignatureFamilies
The families of a signature in a module, built once.
| PARAMETER | DESCRIPTION |
|---|---|
signature
|
The signature.
TYPE:
|
module
|
The declaring module's name.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
SignatureFamilies
|
The families. |