Expand description
A unified, fully-safe ecosystem for moving values between Rust’s type level and value level.
This is the facade crate. It re-exports each of the focused crates
in the workspace under a single namespace, so a single dependency on
reify-reflect (with appropriate features) is enough to use everything.
If you only need one piece, depending on the focused crate directly
gives you a smaller build.
§What is “reification” and “reflection”?
Two complementary directions:
- Reflection is type → value. A type like
S<S<S<Z>>>encodes the number 3 at compile time;core::Reflect::reflecthands you3at runtime. - Reification is value → type. A
u64known only at runtime can be lifted into a callback in which it is genuinely aconst N: u64. Seeconst_reify(re-exported as [const_bridge] when theconst-reifyfeature is enabled).
Everything here is #![deny(unsafe_code)]. There is no unsafe, no
compiler-internal layout assumption, and no unsafeCoerce-style trick.
The Rust borrow checker enforces what GHC’s parametricity enforces in
Haskell’s reflection library.
§Module map
| Module | Crate | Use it for |
|---|---|---|
core | reify_reflect_core | The Reflect trait, the reify scoping function, the Reified branded token, and the RuntimeValue enum. |
nat | reflect_nat | Peano naturals (Z/S<N>), type-level booleans, heterogeneous lists, with optional frunk/typenum bridges. |
graph | reify_graph | Convert Rc<RefCell<T>> or Arc<Mutex<T>> graphs to and from a flat node+edge form, preserving sharing and cycles. |
context | context_trait | Swap out Ord, Hash, Display (or any user-defined trait) for one block of code via WithContext. |
async_trace | async_reify | Wrap futures to record poll events and turn them into an inspectable async step graph. |
[const_bridge] (feature const-reify) | const_reify | Dispatch a runtime u64 in 0..=255 to the matching const N: u64 monomorphization, safely. |
For the #[derive(Reflect)], #[trace_async], and #[reifiable]
proc macros, depend on reflect-derive, async-reify-macros, and
const-reify-derive respectively (or enable the relevant features).
§Quick start
Reflect a type-level number to a runtime value:
use reify_reflect::core::{Reflect, RuntimeValue};
use reify_reflect::nat::{S, Z};
type Three = S<S<S<Z>>>;
assert_eq!(Three::reflect(), RuntimeValue::Nat(3));For deeper walkthroughs, see the guides and the narrative blog post in the source tree.
§Feature flags
| Feature | Default | Effect |
|---|---|---|
serde | yes | Enables Serialize/Deserialize impls in graph and async_trace. |
const-reify | no | Enables the [const_bridge] module. Adds 256 monomorphizations to compile time. |
typenum | no | Bridge between nat and the typenum crate. |
frunk | no | Bridge between nat and frunk’s HList. |
full | no | All of the above. |
Modules§
- async_
trace - Async computation tracing and step graph extraction.
- context
- Runtime-synthesized trait instances scoped to callbacks.
- core
- Core traits and types:
Reflect,reify,Reified,RuntimeValue. - graph
Rc<RefCell<T>>graph reification and reconstruction.- nat
- Type-level naturals (
Z,S), booleans (True,False), and heterogeneous lists (HNil,HCons).