Declarations¶
Indexed-family and constructor declarations.
declarations
¶
Indexed-family and constructor declarations for the QIEC kernel.
FieldDef
dataclass
¶
FieldDef(name: str, type: TypeExpr)
One named, typed field of a constructor.
| PARAMETER | DESCRIPTION |
|---|---|
name
|
The field's display name.
TYPE:
|
type
|
The field's type, which may mention the constructor's telescope.
TYPE:
|
FamilyDecl
dataclass
¶
FamilyDecl(id: FamilyId, name: str, parameters: Telescope, indices: Telescope, constructors: tuple[ConstructorId, ...], closed: bool = True)
A closed or opaque indexed data family.
parameters are uniform across every constructor. indices may be
refined by constructor results and therefore are kept separate even when
both are represented by index binders.
| PARAMETER | DESCRIPTION |
|---|---|
id
|
Stable identity.
TYPE:
|
name
|
Source name, used for display and for the derived type constructor.
TYPE:
|
parameters
|
Binders uniform across every constructor.
TYPE:
|
indices
|
Binders a constructor result may refine. Each must be marked refinable, which is what separates them from parameters.
TYPE:
|
constructors
|
The constructors this family declares, without repetition.
TYPE:
|
closed
|
Whether the constructor list is exhaustive. A closed family admits coverage checking; an opaque one does not.
TYPE:
|
type_constructor
property
¶
type_constructor: TypeConstructorRef
The type constructor this family introduces.
| RETURNS | DESCRIPTION |
|---|---|
TypeConstructorRef
|
A constructor whose identity is derived from the family's, taking the parameters and indices together as its telescope. Deriving rather than storing it keeps the two from drifting apart. |
__post_init__
¶
Reject a family whose binders or constructors are malformed.
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If either telescope is malformed, a name is shared between a parameter and an index, an index is not marked refinable, or a constructor is listed twice. |
Source code in src/quivers/qiec/declarations.py
ConstructorDecl
dataclass
¶
ConstructorDecl(id: ConstructorId, family: FamilyId, name: str, telescope: Telescope, fields: tuple[FieldDef, ...], result_indices: tuple[StaticArgument, ...])
One GADT constructor.
Constructor-local telescope binders are rigid skolems while a branch is
checked. result_indices may mention those binders and thereby refine
the scrutinee indices.
| PARAMETER | DESCRIPTION |
|---|---|
id
|
Stable identity.
TYPE:
|
family
|
The family this constructor belongs to, which must list it.
TYPE:
|
name
|
Source name.
TYPE:
|
telescope
|
Binders local to the constructor. These become rigid skolems while a branch matching it is checked.
TYPE:
|
fields
|
The values the constructor carries, uniquely named.
TYPE:
|
result_indices
|
What the constructor fixes the family's indices to. One per family index, and may mention the local telescope, which is how matching refines the scrutinee's type.
TYPE:
|
__post_init__
¶
Reject a constructor whose telescope or fields are malformed.
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If the telescope is malformed or two fields share a name. |