Kinds¶
A kind says what sort of static argument a binder expects, such as a type or an index. A telescope is an ordered list of binders in which later ones may mention earlier ones (de Bruijn, 1991). For a vector indexed by length, these keep the element type and the length apart from the elements. The module gives kinds, finite enumerated index types, and declaration telescopes.
kinds
¶
Kinds, closed index sorts, and declaration telescopes for QIEC.
DATA_ROW
module-attribute
¶
DATA_ROW = DataRowKind()
The kind of labelled rows of types, written Row in source.
Kind
¶
Kind = TypeKind | EffectKind | RowKind | DataRowKind | 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
didactic-model
¶
Bases: QiecModel
The kind of types.
| PARAMETER | DESCRIPTION |
|---|---|
tag
|
The serialization discriminator; always
TYPE:
|
EffectKind
didactic-model
¶
Bases: QiecModel
The kind of effect interfaces.
| PARAMETER | DESCRIPTION |
|---|---|
tag
|
The serialization discriminator; always
TYPE:
|
RowKind
didactic-model
¶
Bases: QiecModel
The kind of effect rows.
| PARAMETER | DESCRIPTION |
|---|---|
tag
|
The serialization discriminator; always
TYPE:
|
DataRowKind
didactic-model
¶
Bases: QiecModel
The kind of labelled rows of types.
A row of this kind maps distinct labels to types and is the shared argument of a record type and a variant type, so one row variable can stand for the fields of a record and the alternatives of a variant.
| PARAMETER | DESCRIPTION |
|---|---|
tag
|
The serialization discriminator; always
TYPE:
|
ArrowKind
didactic-model
¶
ArrowKind(*, domain: Kind = field(opaque=True, extras=OPAQUE_BY_VALUE), codomain: Kind = field(opaque=True, extras=OPAQUE_BY_VALUE), tag: Literal['arrow'] = 'arrow')
Bases: QiecModel
The kind of a constructor from one kind to another.
| PARAMETER | DESCRIPTION |
|---|---|
domain
|
The kind of the argument.
TYPE:
|
codomain
|
The kind of the result.
TYPE:
|
tag
|
The serialization discriminator; always
TYPE:
|
NatSort
didactic-model
¶
Bases: QiecModel
The sort of natural-number indices.
| PARAMETER | DESCRIPTION |
|---|---|
tag
|
The serialization discriminator; always
TYPE:
|
ShapeSort
didactic-model
¶
Bases: QiecModel
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:
|
ContextSort
didactic-model
¶
Bases: QiecModel
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
didactic-model
¶
UserIndexSort(*, name: str, constructors: tuple[str, ...] = field(opaque=True, extras=OPAQUE_BY_VALUE), arities: tuple[int, ...] = field(default=(), opaque=True, extras=OPAQUE_BY_VALUE), tag: Literal['user'] = 'user')
Bases: QiecModel
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:
|
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
didactic-model
¶
TypeBinder(*, name: str, kind: Kind = field(default=TYPE, opaque=True, extras=OPAQUE_BY_VALUE), refinable: bool = False, tag: Literal['type'] = 'type')
Bases: QiecModel
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.
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:
|
IndexBinder
didactic-model
¶
IndexBinder(*, name: str, sort: IndexSort = field(opaque=True, extras=OPAQUE_BY_VALUE), refinable: bool = False, tag: Literal['index'] = 'index')
Bases: QiecModel
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
didactic-model
¶
Bases: QiecModel
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. |
Source code in src/quivers/qiec/kinds.py
Cited sources¶
N. G. de Bruijn. Telescopic Mappings in Typed Lambda Calculus. Information and Computation, 91(2):189–204, 1991. doi:10.1016/0890-5401(91)90066-B.