Module table

Module table 

Source
Expand description

Table representation of hugr modules.

Instead of directly nesting data structures, we store them in tables and refer to them by their id in the table. Variables, symbols and links are fully resolved: uses refer to the id of the declaration. This allows the table representation to be read from the binary format and imported into the core data structures without having to perform potentially costly name resolutions.

The tabling is also used for deduplication of terms. In practice, many terms will share the same subterms, and we can save memory and validation time by storing them only once. However we allow non-deduplicated terms for cases in which terms carry additional identity over just their structure. For instance, structurally identical terms could originate from different locations in a text file and therefore should be treated differently when locating type errors.

This format is intended to be used as an intermediary data structure to convert between different representations (such as the binary format, the text format or internal compiler data structures). To make this efficient, we use arena allocation via the bumpalo crate to efficiently construct and tear down this representation. The data structures in this module therefore carry a lifetime parameter that indicates the lifetime of the arena.

Structs§

LinkId
The id of a link consisting of its region and the link index.
LinkIndex
Index of a link in a hugr graph.
Module
A module consisting of a hugr graph together with terms.
Node
Nodes in the hugr graph.
NodeId
Id of a node in a hugr graph.
Package
A package consisting of a sequence of Modules.
Param
A parameter to a function or alias.
Region
A region in the hugr.
RegionId
Id of a region in a hugr graph.
RegionScope
Information about the scope defined by a closed region.
Symbol
A symbol.
TermId
Id of a term in a hugr graph.
VarId
The id of a variable consisting of its node and the variable index.

Enums§

ModelError
Errors that can occur when traversing and interpreting the model.
Operation
Operations that nodes can perform.
SeqPart
A part of a list/tuple term.
Term
A term in the compile time meta language.

Traits§

View
Trait for views into a Module.

Type Aliases§

VarIndex
An index of a variable within a node’s parameter list.