Type-level strings and paths
Recovering a field name as runtime data, and joining the paths a lookup follows.
Overview
Context-Generic Programming (CGP) encodes field and variant names as types, so that a name can drive trait resolution. A program eventually needs those names as ordinary strings, to report a missing field or to build a key, and two of these traits are how a name comes back out, while the third joins the type-level paths a redirected lookup follows. None of them is in the prelude, and they sit in two different modules, which is the group's sharpest edge.
StaticStringdecodes aSymbol!into a compile-time&'static strconstant. This is the one to reach for when you need a name as data. Import it fromcgp::core::field::traits.StaticFormatwrites a type-level string into a formatter, and backs theDisplayimpl onSymbol, so aDisplaybound is usually all you need. Reach for the trait itself only where a value to format is missing. Import it fromcgp::core::base::traits.ConcatPathjoins two type-levelPath!routes, the path-level analogue ofConcatProduct. Import it fromcgp::core::base::traits.
The ideas behind them
- Namespaces: reusable wiring tables and the paths that route into them.
- Extensible records: where field-name types are put to work at scale.
An AI agent wrote this page using the CGP knowledge base. Its content was verified against the library's source. See How AI is used in this project.