Kinds¶
Kinds, closed index sorts, and declaration telescopes.
kinds
¶
Kinds, closed index sorts, and declaration telescopes for QIEC.
Kind
¶
Kind = TypeKind | EffectKind | RowKind | ArrowKind
The kind of a static binder: a type, an effect, a row, or an arrow between kinds.
IndexSort
¶
IndexSort = NatSort | ShapeSort | ContextSort | UserIndexSort
The sort of an index binder: naturals, shapes, contexts, or a declared sort.
TelescopeBinder
¶
TelescopeBinder = TypeBinder | IndexBinder | EffectBinder
One binder of a declaration telescope: a type, an index, or an effect binder.
Telescope
¶
Telescope = tuple[TelescopeBinder, ...]
The static binders a declaration takes, in order; later binders may mention earlier ones.
TypeKind
dataclass
¶
The kind of types.
| PARAMETER | DESCRIPTION |
|---|---|
tag
|
The serialization discriminator; always
TYPE:
|
EffectKind
dataclass
¶
The kind of effect interfaces.
| PARAMETER | DESCRIPTION |
|---|---|
tag
|
The serialization discriminator; always
TYPE:
|
RowKind
dataclass
¶
The kind of effect rows.
| PARAMETER | DESCRIPTION |
|---|---|
tag
|
The serialization discriminator; always
TYPE:
|
ArrowKind
dataclass
¶
NatSort
dataclass
¶
The sort of natural-number indices.
| PARAMETER | DESCRIPTION |
|---|---|
tag
|
The serialization discriminator; always
TYPE:
|
ShapeSort
dataclass
¶
The sort of shapes, optionally restricted to a fixed rank.
| PARAMETER | DESCRIPTION |
|---|---|
rank
|
The number of dimensions, or None for any rank. A binder of unspecified rank accepts a shape of any rank, which is what makes a rank-polymorphic signature expressible.
TYPE:
|
tag
|
Discriminator for the index-sort union.
TYPE:
|
__post_init__
¶
Reject a negative rank.
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If |
ContextSort
dataclass
¶
A logic-program context indexed by a stable signature name.
| PARAMETER | DESCRIPTION |
|---|---|
signature
|
The name of the signature whose contexts inhabit this sort.
TYPE:
|
tag
|
The serialization discriminator; always
TYPE:
|
UserIndexSort
dataclass
¶
UserIndexSort(name: str, constructors: tuple[str, ...], arities: tuple[int, ...] = (), tag: Literal['user'] = 'user')
A closed user-defined index datatype.
Constructor names are part of the sort identity. Open index sorts are deliberately absent from the first kernel because they make coverage unstable under separate compilation.
| PARAMETER | DESCRIPTION |
|---|---|
name
|
The sort's name, part of its identity.
TYPE:
|
constructors
|
Constructor names, unique and part of the identity. Two sorts with the same name and different constructors are different sorts, which is what keeps coverage decidable.
TYPE:
|
arities
|
Argument count per constructor, positionally aligned with
TYPE:
|
tag
|
Discriminator for the index-sort union.
TYPE:
|
__post_init__
¶
Default the arities and reject a malformed sort.
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If the name is empty, there are no constructors, a constructor name repeats, the arities do not align with the constructors, or an arity is negative. |
Source code in src/quivers/qiec/kinds.py
constructor_arity
¶
The number of arguments one constructor takes.
| PARAMETER | DESCRIPTION |
|---|---|
name
|
The constructor name.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
int
|
Its arity, zero for a nullary constructor. |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If the sort has no such constructor. The sort is closed, so an unknown name is an error rather than an open extension. |
Source code in src/quivers/qiec/kinds.py
TypeBinder
dataclass
¶
A telescope binder for a type or effect-kinded static argument.
| PARAMETER | DESCRIPTION |
|---|---|
name
|
The binder's display name.
TYPE:
|
kind
|
The kind of the bound argument. |
refinable
|
Whether case analysis may refine the bound argument; true for a family's indices and false for its uniform parameters.
TYPE:
|
tag
|
The serialization discriminator; always
TYPE:
|
IndexBinder
dataclass
¶
IndexBinder(name: str, sort: IndexSort, refinable: bool = False, tag: Literal['index'] = 'index')
A telescope binder for an index argument.
| PARAMETER | DESCRIPTION |
|---|---|
name
|
The binder's display name.
TYPE:
|
sort
|
The closed index sort of the bound argument.
TYPE:
|
refinable
|
Whether case analysis may refine the bound argument; true for a family's indices and false for its uniform parameters.
TYPE:
|
tag
|
The serialization discriminator; always
TYPE:
|
EffectBinder
dataclass
¶
A telescope binder for an effect argument.
| PARAMETER | DESCRIPTION |
|---|---|
name
|
The binder's display name.
TYPE:
|
refinable
|
Whether case analysis may refine the bound argument.
TYPE:
|
tag
|
The serialization discriminator; always
TYPE:
|
validate_telescope
¶
validate_telescope(telescope: Telescope) -> None
Reject duplicate names in one dependent telescope.
| PARAMETER | DESCRIPTION |
|---|---|
telescope
|
The binders to check, in order.
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If a binder name is empty or repeats. Later binders may depend on earlier ones, so a repeated name would make a reference ambiguous. |