Expand description
Query-based compilation system for BHC.
This crate provides the infrastructure for incremental, demand-driven compilation using a query-based architecture similar to rustc’s query system and salsa.
§Overview
The query system allows the compiler to:
- Incrementally recompute only what has changed between compilations
- Demand-driven evaluation where queries are only computed when needed
- Automatic memoization of query results
- Cycle detection for recursive queries
§Architecture
Queries are defined as traits that can be implemented by a database. The database stores memoized results and tracks dependencies between queries.
┌─────────────────────────────────────────────────────┐
│ QueryDatabase │
│ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │
│ │ Query A │ │ Query B │ │ Query C │ │
│ │ (cached) │──│ (cached) │──│ (pending) │ │
│ └─────────────┘ └─────────────┘ └─────────────┘ │
│ Dependencies │
└─────────────────────────────────────────────────────┘Structs§
- Memoized
Result - A memoized query result with revision tracking.
- QueryId
- A unique identifier for a query invocation.
- Query
Runtime - A runtime for executing queries with a database.
- Query
Storage - Storage for a specific query type.
- Revision
- A revision number tracking database state changes.
- Simple
Database - A simple in-memory query database implementation.
Enums§
- Query
Error - Error types for the query system.
- Query
State - The state of a query computation.
Traits§
- Input
Query - Marker trait for input queries that can be set directly.
- Query
- A query definition with its computation function.
- Query
Database - The central database trait that all query databases must implement.
- Query
Key - Trait for types that can be used as query keys.
- Query
Value - Trait for types that can be used as query values.
Type Aliases§
- Query
Result - Result type for query computations.