QIEC tooling¶
These functions expose analysis and symbol metadata of the checked Quivers Indexed Effect Core (QIEC) to diagnostics and editor features, linking source locations, names, and types to the corresponding core declarations.
Internal module
This module is an implementation detail of the compiler and its
tooling. Its __all__ is empty, so none of the names below are
part of the public API, and they may change without notice.
qiec_tooling
¶
Shared QIEC analysis and symbol metadata for interactive tooling.
The runtime compiler and the QIEC lowerer are deliberately separate pipelines.
This module is the small adapter used by qvr check, the REPL, and the LSP:
it lowers and validates QIEC declarations, while continuing to compile the
other QVR declarations in the same source module with their compiler.
QiecToolingDiagnostic
didactic-model
¶
Bases: Model
A frontend-neutral QIEC diagnostic.
QiecBinding
didactic-model
¶
QiecBinding(*, name: str, kind: QiecBindingKind, declaration: HeldValue = field(opaque=True, extras=OPAQUE_BY_IDENTITY), owner: Statement = field(opaque=True, extras=OPAQUE_BY_IDENTITY), scope: tuple[int, int] | None = field(default=None, opaque=True, extras=OPAQUE_BY_VALUE), provenance: MetaProvenance | None = None)
Bases: QiecModel
One source-level name exposed to completion and navigation.
scope
class-attribute
instance-attribute
¶
The 1-based line range the binding is visible over.
None for a module-level declaration, which is visible throughout.
A local binder carries the span of the region that may refer to it,
so a tool can offer it at a position inside that region and nowhere
else.
provenance
class-attribute
instance-attribute
¶
provenance: MetaProvenance | None = None
The checked splice or deriving site for a generated name.
is_local
property
¶
Whether this binding is confined to part of one declaration.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
True when the binding carries a lexical scope, which is how a caller distinguishes a name that may be offered anywhere in the module from one that may not. |
qualified_name
property
¶
Return the declaration-qualified identity of this binding.
Signature members are scoped by their owning index, family, or effect. Top-level declarations already have a module-level identity, so their qualified spelling is just their authored name.
| RETURNS | DESCRIPTION |
|---|---|
str
|
|
semantic_kind
property
¶
The token class a highlighter should give this binding.
| RETURNS | DESCRIPTION |
|---|---|
str
|
One of |
covers
¶
Whether this binding is visible at a source line.
| PARAMETER | DESCRIPTION |
|---|---|
line
|
1-based line number.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
bool
|
True for a module-level binding at any line, and for a local binding only inside its own span. A tool that offers a local outside its span is offering a name that does not resolve. |
Source code in src/quivers/dsl/qiec_tooling.py
ToolingAnalysis
didactic-model
¶
ToolingAnalysis(*, compiler: Compiler = field(opaque=True, extras=OPAQUE_BY_IDENTITY), env: dict[str, HeldValue] = field(opaque=True, extras=OPAQUE_BY_IDENTITY), non_qiec_module: Module = field(opaque=True, extras=OPAQUE_BY_IDENTITY), qiec_module: QiecModule | None = field(opaque=True, extras=OPAQUE_BY_VALUE), qiec_diagnostics: tuple[QiecToolingDiagnostic, ...] = field(opaque=True, extras=OPAQUE_BY_VALUE), compile_error: CompileError | None = field(opaque=True, extras=OPAQUE_BY_IDENTITY))
Bases: QiecModel
The two elaboration products needed by user-facing tools.
CallSite
didactic-model
¶
CallSite(*, callee: str, owner: str, line: int, col: int, static_arguments: tuple[str, ...] = (), argument_count: int = 0)
Bases: Model
One call of a named computation in a body.
| PARAMETER | DESCRIPTION |
|---|---|
callee
|
The computation called.
TYPE:
|
owner
|
The name of the declaration the call sits in.
TYPE:
|
line
|
The call's 1-based line.
TYPE:
|
col
|
The call's 0-based column, at the callee's name.
TYPE:
|
static_arguments
|
The call's static arguments in source form, in order.
TYPE:
|
argument_count
|
The number of value arguments passed.
TYPE:
|
is_qiec_statement
¶
is_qiec_statement(statement: Statement) -> bool
Return whether statement belongs to the QIEC surface.
| PARAMETER | DESCRIPTION |
|---|---|
statement
|
The parsed statement to classify.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
bool
|
True for a QIEC declaration. This is the split the tooling layer works from: QIEC statements go to the lowerer and everything else to the existing compiler. |
Source code in src/quivers/dsl/qiec_tooling.py
analyze_module
¶
analyze_module(module: Module, *, module_name: str, file_path: str | None = None, compile_categorical: bool = True) -> ToolingAnalysis
Run the QIEC lowerer and existing compiler without conflating them.
QIEC failures are returned as stable diagnostics. Existing compiler errors remain separately typed so callers can retain their established diagnostic code and presentation.
| PARAMETER | DESCRIPTION |
|---|---|
module
|
The parsed module, carrying both QIEC and ordinary declarations.
TYPE:
|
module_name
|
Name the QIEC lowerer derives stable identities from. Two modules of the same name produce the same identities, so this must match what the rest of the pipeline uses.
TYPE:
|
file_path
|
Path recorded on diagnostics, or None when the source has no file.
TYPE:
|
compile_categorical
|
Also compile ordinary declarations. A caller with an independently established family-shape error may disable this pass while retaining QIEC diagnostics from the shared analyzer.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
ToolingAnalysis
|
The compiler, its environment, the non-QIEC projection, the lowered QIEC module when lowering succeeded, the QIEC diagnostics, and the compiler error when one occurred. Nothing raises: a tool needs whichever half succeeded even when the other failed. |
Source code in src/quivers/dsl/qiec_tooling.py
291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 | |
target_diagnostics
¶
target_diagnostics(checked: QiecModule, source: Module, target: str) -> tuple[QiecToolingDiagnostic, ...]
Check a target against an already checked source module.
Capability diagnostics take precedence over target-plan refusals. The authoritative transpile preflights perform both checks; this adapter only translates their results into the diagnostic record shared by tools. It neither parses nor elaborates the source again. A request-local preparation shares the checked module's structural projection between capability checking and planning.
| PARAMETER | DESCRIPTION |
|---|---|
checked
|
The checked QIEC projection of
TYPE:
|
source
|
The corresponding parsed source module.
TYPE:
|
target
|
The transpile target.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
tuple[QiecToolingDiagnostic, ...]
|
Capability failures with their source origins, or plan refusals with the original structured kinds and messages. An empty tuple means these preflights admitted the module; rendering may impose further restrictions. |
Source code in src/quivers/dsl/qiec_tooling.py
qiec_diagnostic
¶
qiec_diagnostic(error: Exception) -> QiecToolingDiagnostic
Normalize lowerer/kernel exceptions into the public QIEC code set.
| PARAMETER | DESCRIPTION |
|---|---|
error
|
The exception raised by the lowerer or the kernel.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
QiecToolingDiagnostic
|
A diagnostic whose code is drawn from the published set. An exception carrying a recognised code keeps it; anything else is classified by its text, so a caller always receives a stable code rather than an implementation detail. |
Source code in src/quivers/dsl/qiec_tooling.py
qiec_bindings
¶
qiec_bindings(module: Module, *, generated: tuple[GeneratedDeclaration, ...] = ()) -> tuple[QiecBinding, ...]
Return authored and generated top-level names and signature members.
| PARAMETER | DESCRIPTION |
|---|---|
module
|
The parsed module to read.
TYPE:
|
generated
|
The checked generated declarations visible in this source.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
tuple[QiecBinding, ...]
|
Authored names in source order, followed by generated names in
splice order. Each declaration appears with the members it owns.
Names local to a body come from
|
Source code in src/quivers/dsl/qiec_tooling.py
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 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 | |
pattern_bound_names
¶
pattern_bound_names(pattern: QiecPattern) -> tuple[QiecLocalBinding | QiecTypeName, ...]
The names a pattern may bind, as the parser sees them.
A bare name in a pattern is a variable unless the matched type declares a nullary constructor of that name, which only elaboration can tell; tools offer every bare name as a possible binder.
| PARAMETER | DESCRIPTION |
|---|---|
pattern
|
The pattern.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
tuple[QiecLocalBinding | QiecTypeName, ...]
|
The value names as local bindings (with their annotations) and the static names as type names, in source order. |
Source code in src/quivers/dsl/qiec_tooling.py
qiec_local_bindings
¶
qiec_local_bindings(module: Module) -> tuple[QiecBinding, ...]
Every binder local to a declaration body, in source order.
These are the names a tool may offer only inside part of a file:
let bindings, a handler clause's parameters, a scoped instance, and
the names a case branch binds. Each carries the line range it is
visible over, so a caller filters with
QiecBinding.covers.
| PARAMETER | DESCRIPTION |
|---|---|
module
|
The parsed module to traverse.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
tuple[QiecBinding, ...]
|
The local bindings. A module with no QIEC computation or handler declarations yields nothing. |
Source code in src/quivers/dsl/qiec_tooling.py
893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 | |
qiec_binding_map
¶
qiec_binding_map(module: Module, *, generated: tuple[GeneratedDeclaration, ...] = ()) -> dict[str, QiecBinding]
Return unambiguous source identities for QIEC bindings.
Every signature member is available through Owner.member. A bare
member spelling remains available when exactly one declaration owns that
spelling and it does not collide with a top-level declaration. This keeps
the convenient :type get form for a single effect while preventing a
later Writer.get from silently replacing Reader.get.
| PARAMETER | DESCRIPTION |
|---|---|
module
|
The parsed module to read.
TYPE:
|
generated
|
The checked generated declarations visible in this source.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
dict[str, QiecBinding]
|
Spelling to binding. A member owned by two declarations appears only under its qualified spellings, so a lookup never silently resolves to one of two equally good answers. |
Source code in src/quivers/dsl/qiec_tooling.py
qiec_binding_candidates
¶
qiec_binding_candidates(module: Module, name: str, *, generated: tuple[GeneratedDeclaration, ...] = ()) -> tuple[QiecBinding, ...]
Return every binding matching an authored or qualified spelling.
| PARAMETER | DESCRIPTION |
|---|---|
module
|
The parsed module to search.
TYPE:
|
name
|
A bare member name or a qualified
TYPE:
|
generated
|
The checked generated declarations visible in this source.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
tuple[QiecBinding, ...]
|
Matching bindings. A qualified spelling yields at most one. A bare spelling yields every owner that declares it, which is what lets a caller report an ambiguity rather than resolve it arbitrarily. |
Source code in src/quivers/dsl/qiec_tooling.py
qiec_env_kinds
¶
qiec_env_kinds(module: Module, *, generated: tuple[GeneratedDeclaration, ...] = ()) -> dict[str, str]
Return semantic-token classifications for QIEC names.
| PARAMETER | DESCRIPTION |
|---|---|
module
|
The parsed module to classify.
TYPE:
|
generated
|
The checked generated declarations visible in this source.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
dict[str, str]
|
Spelling to token class, for the language server's semantic token legend. Only unambiguous spellings appear, since the map it is built from omits the rest. |
Source code in src/quivers/dsl/qiec_tooling.py
qiec_surface_values
¶
qiec_surface_values(module: Module, *, generated: tuple[GeneratedDeclaration, ...] = ()) -> dict[str, object]
Expose QIEC declarations in the shared inspection environment.
| PARAMETER | DESCRIPTION |
|---|---|
module
|
The parsed module to expose.
TYPE:
|
generated
|
The checked generated declarations visible in this source.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
dict[str, object]
|
Spelling to the authored or generated declaration's source AST node. |
Source code in src/quivers/dsl/qiec_tooling.py
render_operation
¶
render_operation(operation: OperationDef) -> str
Render one operation of an effect interface as its declaration line.
| PARAMETER | DESCRIPTION |
|---|---|
operation
|
The operation.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
str
|
|
Source code in src/quivers/dsl/qiec_tooling.py
render_effect
¶
render_effect(effect: EffectDef) -> str
Render an effect interface as its declaration.
| PARAMETER | DESCRIPTION |
|---|---|
effect
|
The interface.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
str
|
The |
Source code in src/quivers/dsl/qiec_tooling.py
prelude_effect
¶
prelude_effect(name: str) -> EffectDef | None
The prelude interface of a name, if the prelude declares one.
| PARAMETER | DESCRIPTION |
|---|---|
name
|
The interface's name.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
EffectDef | None
|
The interface, or |
Source code in src/quivers/dsl/qiec_tooling.py
instance_effect_name
¶
instance_effect_name(module: Module, instance: str) -> str | None
The interface a module-level instance declaration instantiates.
| PARAMETER | DESCRIPTION |
|---|---|
module
|
The parsed module.
TYPE:
|
instance
|
The instance's name.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
str | None
|
The interface's name, or |
Source code in src/quivers/dsl/qiec_tooling.py
effect_operation_names
¶
effect_operation_names(module: Module, effect: str) -> tuple[str, ...]
The operations of an interface, declared in the module or by the prelude.
| PARAMETER | DESCRIPTION |
|---|---|
module
|
The parsed module.
TYPE:
|
effect
|
The interface's name.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
tuple[str, ...]
|
The operation names in declaration order; empty for an unknown interface. A module's own declaration shadows the prelude's. |
Source code in src/quivers/dsl/qiec_tooling.py
call_sites
¶
Every call of a named computation in a module.
| PARAMETER | DESCRIPTION |
|---|---|
module
|
The parsed module.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
tuple[CallSite, ...]
|
The calls in computation bodies, handler clause bodies, and program bodies, in source order. A recursive call is a call whose callee is its owner. |
Source code in src/quivers/dsl/qiec_tooling.py
call_site_at
¶
The call whose callee name covers a source position.
| PARAMETER | DESCRIPTION |
|---|---|
module
|
The parsed module.
TYPE:
|
line
|
The 0-based line.
TYPE:
|
col
|
The 0-based column.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
CallSite | None
|
The call, or |
Source code in src/quivers/dsl/qiec_tooling.py
instantiated_call_signature
¶
Render the signature a call instantiates its callee at.
| PARAMETER | DESCRIPTION |
|---|---|
module
|
The parsed module.
TYPE:
|
site
|
The call.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
str | None
|
The callee's declaration line with each static binder replaced
by the call's argument for it, and the |
Source code in src/quivers/dsl/qiec_tooling.py
qualified_operation_signature
¶
qualified_operation_signature(module: Module, spelling: str) -> str | None
Render an operation addressed through its interface or an instance.
| PARAMETER | DESCRIPTION |
|---|---|
module
|
The parsed module.
TYPE:
|
spelling
|
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
str | None
|
The operation's declaration line under the given spelling, with
an instance's static arguments substituted for the interface's
binders ( |
Source code in src/quivers/dsl/qiec_tooling.py
1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 | |
qiec_module_name
¶
Derive a deterministic source module name for editor/CLI entry points.
The name enters every stable identity the lowerer derives, so it has to depend on the path alone and not on how the path was spelled.
| PARAMETER | DESCRIPTION |
|---|---|
file_path
|
The source path, possibly a
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
str
|
The path's stem, |