Skip to content

[Blog post] Add Trying Incoherent Rust today with Context-Generic Programming - #5

Merged
soareschen merged 87 commits into
mainfrom
incoherent-rust
Nov 28, 2026
Merged

soareschen merged 87 commits into
mainfrom
incoherent-rust

Conversation

@soareschen

@soareschen soareschen commented May 6, 2026 •

Copy link
Copy Markdown
Contributor

Overview

[claude-opus-5-5] In March, Nadrieril's posts on explicit trait proofs and Boxy's An Incoherent Rust started a discussion about traits that opt out of coherence. The discussion has since become the types team's Dictionary Passing Style Experiment. CGP already expresses part of that design space on stable Rust, but the site lacked writing that set CGP against it. This PR adds a deep-dive post for language-design readers, with the documentation pages it links, so those readers can see which parts of Incoherent Rust CGP lets them try today and where it falls short:

  • The post: Trying Incoherent Rust today with Context-Generic Programming desugars incoherent traits, named impls, incoherent trait bounds, struct bindings, and contexts and capabilities into CGP. It then compares CGP's context type with the dictionaries of dictionary-passing style, and states CGP's limits and the ideas it suggests for Incoherent Rust. Its CGP snippets compile in example-code, and the snippets that need the unstable const_type_name feature compile in a new example-code-nightly crate.
  • Comparisons: the site lacked a comparison of the languages that already give up global coherence. A new Traits without coherence page compares Cairo, Scala, OCaml's modular implicits, and Haskell with CGP. Rust's own proposals covers the discussion since March, and both pages cite the post's matching sections and list it under Where to go next. Algebraic effects develops the coeffect reading the post points to. Dynamic dispatch is rewritten around how a call finds the code it runs, through one greeting example, and its title shortens from Dynamic dispatch, dynamic typing, and prototypal inheritance.
  • Concepts: the post links the Concepts pages instead of repeating their explanations, so those pages gain the passages it relies on. A new Type-level tables page explains in plain Rust the compile-time map behind a wiring table, including nested tables and prototype chains. Namespaces, Consumer and provider traits, Higher-order providers, Implicit arguments, and Modularity hierarchy gain passages, and Checking your wiring explains the IsProviderFor marker that Consumer and provider traits now names. Bypassing coherence, Aggregate providers, Type-level DSLs, the Concepts index, and the wiring and namespace reference pages link the new page. Bypassing coherence and Modularity hierarchy, the two Concepts pages that discuss coherence directly, also cite the post where it develops their argument.

The documentation pages' provenance footers made the agent their subject, as in "An AI agent wrote this page", and several joined a verification claim to that sentence with ", and". Each footer now makes the page its subject, as the post's own line does, and gives each verification claim its own sentence: "This page was written by an AI agent from the CGP knowledge base." Contribute no longer has a footer, and the AI disclosure page no longer has its How pages are marked section.

Impact

  • A second snippet crate: example-code-nightly pins its nightly in rust-toolchain.toml, and test-deploy.yaml gains a Nightly snippet tests job that runs it. AGENTS.md says when a snippet belongs in that crate.
  • Sidebar order: the Concepts pages after Type-level tables move down one position, and Policy-based design moves from second place to just before the new Traits without coherence page, at the end of the Comparisons list.
  • Glossary: a new entry defines prototype chain, and dynamic dispatch now covers lookup by name along a chain of dictionaries as well as method tables.

Areas needing attention

  • The collaboration offer's team: the post's conclusion offers to work with the Rust compiler team, while the rest of the post credits the types team with the dictionary-passing work. Decide whether the offer should name the types team instead.
  • The footer rewrite: a script rewrote the footer of every documentation page that has one, so outside the pages named above, each changed page differs only in its footer.
  • The sections that judge other tools: Dynamic dispatch's What each approach costs and Where runtime dispatch is the better choice, and the matching sections of Traits without coherence, describe other communities' languages and say where they are the better choice. Their fairness depends on the author's reading rather than on a check against code.

[claude-opus-5-5] The draft answered the March posts on dictionary
passing and incoherent traits, and most of its CGP snippets no longer
compiled. The post now opens on the discussion as it stands, corrects
its claim that CGP resolves cyclic dependencies, quotes its sources
exactly, and links the website's pages for the primer and related
work, with a placeholder for a comparison page still to come. Its CGP
code compiles in example-code, which gains cgp-serde, cgp-serde-json,
cgp-error-anyhow, typed-arena, and hypershell as dev-dependencies for
the arena and Hypershell examples.
[claude-opus-5-5] The post's illustrative blocks had typos and
inconsistencies, such as call syntax in the TIR dictionary example and
an argument missing from the scoped-impl example, and its prose carried
hedges and repetition. The revision fixes those blocks, states that the
context is the consumer trait's `Self`, drops an unverified claim about
formalizing dictionary-passing style, links the `open` statement's
reference and the modularity hierarchy, and gives the whole post a
plain-language pass.
[claude-opus-5-5] The post turned Boxy's `const NAME` into a function,
because `RealName` computes it with `core::any::type_name`, which is not
const-stable, and readers could take that for a CGP limitation. The
`Name` snippets now keep the constant and open with
`#![feature(const_type_name)]`, and the post says the feature comes
from the standard library. A new `example-code-nightly` crate, pinned
to the nightly `cargo-cgp` uses, checks them with the struct-binding
compile-fail fixture, a CI job runs it, and `AGENTS.md` sends such
snippets there.
[claude-opus-5-5] The context-as-dictionary section lowered the CGP
`Clone` example into a hand-written TIR listing that repeated what the
prose already argued. The listing is gone, and the paragraphs after it
state the lowering as a hypothetical in plain prose.
[claude-opus-5-5] Two sentences tied CGP's features to the releases
that introduced them: implicit arguments to v0.7.0 and namespaces to
v0.8.0. The version numbers date the post without helping the
argument, so both sentences now name the features alone.
[claude-opus-5-5] The page cited Nadrieril's first post by its old
title, called dictionary passing a design sketch, and said nothing of
the types-team goal, the work on which cyclic impls are sound, or where
CGP's context stops helping. It now names the goal and the cycles
posts, and explains that a provider needing its own instance overflows
with `E0275`, as the expression interpreter's dispatch layers show.
[claude-opus-5-5] Readers following the incoherent-Rust discussion had
no page setting Cairo's named impls beside the other trait systems that
allow several impls of one trait for one type; Rust's own proposals
covered Cairo in one subsection. The new page compares Cairo, Scala's
givens, OCaml's modular implicits, Haskell's overlapping instances, and
Boxy's sketch on how each makes that choice, and shows CGP fixing it on
the context, with its CGP code checked in `example-code`. The index, the
coherence concept page, and Rust's own proposals now link it.
[claude-opus-5-5] The post's Related Work paragraph pointed at the
comparison through a placeholder. The comparison now sits on the same
branch, so the paragraph links it directly.
[claude-opus-5-5] The page referred to a Cairo serializer it never
showed, called Haskell's global instances what most code wants, and
claimed CGP has none of the soundness hazards of incoherent instances.
It now ties the CGP example to Cairo's `ArrayDescribe`, states where
global instances fit, and limits the coherence claim to what Rust's
checks ensure: the compiler never picks between two candidates.
[claude-opus-5-5] Several passages added to Traits without coherence
and Rust's own proposals joined claims with semicolons, stated a cause
twice, or left a pronoun unclear. They now give each claim its own
sentence and name what they refer to.
[claude-opus-5-5] The page compared Boxy's incoherent-Rust sketch
beside Cairo, Scala, modular implicits, and Haskell, though Rust's own
proposals already covers it, and the comparisons listed this page and
Policy-based design near the top. The page now compares the four other
systems, the post's sentence about it follows, and both pages sit at
the end of the sidebar and the index's routing table.
[claude-opus-5-5] The page kept a short Cairo subsection and several
Cairo examples after Traits without coherence took over that
comparison, though Cairo is not one of Rust's own proposals. The
section, the Cairo examples, and the Cairo source are gone, the
remaining sentences on inference from scope link the other page, and
Where to go next lists it.
[claude-opus-5-5] After the Cairo example left the vocabulary table,
its higher-order-provider row named an impl passed at a call, which the
row above already covers. The row now names a generic impl that takes
another impl as a parameter, and the passage below it says how
`#[use_provider]` writes that impl.
[claude-opus-5-5] The related-work paragraph named Haskell's overlapping
and incoherent instances, but "Lessons for Rust" counted three answers
and left Haskell out. The lessons now give Haskell's global answer
with exceptions beside inference from scope, explicit naming, and the
context, with the warning GHC's manual gives for its exceptions.
[claude-opus-5-5] The post alternated "context and capabilities" with
the proposal's own "contexts and capabilities", and kept a cleft, two
idioms, a delayed subject, and "dynamic-scoped". They now read
directly, with the proposal named as its author titles it.
[claude-opus-5-5] The new sentence on Haskell's global answer said it
keeps most code simple, which no source states, and its "its manual"
could read as Haskell's. It now says a single global answer needs no
wiring and names GHC's manual as the source of the warning.
[claude-opus-5-5] Some passages still held back their point behind
filler such as "it is worth asking" and "This means that", stacked
qualifiers, or long sentences that ran several claims together. They
now state each point directly in the author's voice, with the code
blocks and headings unchanged.
[claude-opus-5-5] The post answers posts from March but appears in
November, with no word on why. A note after the excerpt now says it was
drafted in April as a quick response, held for time and the v0.8.0
work, and only slightly revised.
[claude-opus-5-5] The *Prototype chains* leaf returned the literal "Bar",
where every other type-level lookup on the page answers with
`type_name` and its test compares against `type_name::<Bar>()`. The leaf
now returns `type_name::<Self>()`, and the comparison page's baseline
bound names `HasStaticStringFor<FooKey>` instead of the removed
`Describe`.
[claude-opus-5-5] The Dynamic dispatch comparison ran the keyed lookup of
Type-level tables through a tag, function-pointer tables, dictionary
chains, passed dictionaries, and multiple dispatch, and compared how
each chooses types. It now follows one greeting: JavaScript and Python
lookup with a one-level prototype, Java, Rust dyn, and Go method
tables, and CGP's providers with implicit fields, the table on each
context, the checks that reject the wrong greeter and the missing
entry, and an aggregate provider as the prototype. The mirror and the
two fixtures follow, and Namespaces drops its link to the page, which
no longer covers namespaces.
[claude-opus-5-5] The Java paragraph joined the JVM's method selection with
the example's lead-in, and the prototype comparison ran past the line
width. The lead-in is its own paragraph, and the line is rewrapped.
[claude-opus-5-5] The page named vtables in Go, left the JavaScript
example's TypeError line unexplained, omitted Go beside the consumer
trait's interface, and named the dyn-compatibility rules and the
Type-level tables cycle without linking them. It now says Go's
interfaces, explains the missing method, links both, and splits and
rewraps two long passages.
[claude-opus-5-5] The page described C++ virtual methods and multiple
dispatch in prose, beside examples that show neither. Both paragraphs
go, with their family-table entries and their sources.
[claude-opus-5-5] The costs listed missing methods but not the
JavaScript example's silent `undefined` for a missing field, the family
table called the first family "Dictionary" under a heading on name
lookup, and the first use of "component" lacked its glossary link. The
costs now name the silent field, the row reads "Name lookup", and the
term links the glossary.
[claude-opus-5-5] A natural-writing pass found the CGP section still
opening on "every family" after the page kept two, two tables without a
lead-in, and several sentences joining separate claims with a semicolon
or "and". The opening now counts both families with CGP's wiring, each
table has a lead-in, and those sentences are split or reworded.
[claude-opus-5-5] A second natural-writing pass found sentences still
joining separate claims with "where", a semicolon, or "and", an
ambiguous "The lookup", and a trait-object sentence that read as a
non sequitur after the survey. Those sentences are split or reworded,
and the foreign-types passage now leads with what runtime field access
reaches before CGP's limit.
[claude-opus-5-5] The incoherent-Rust post's primer stated the first
level of bypassing coherence in prose only, so the section went from a
summary straight to the parameter-targeted `Serialize<T>`. The primer
now shows that level in code: serde's `Serialize` redefined as a
component, a `Display`-based provider, and `Person` wiring it. The
`Serialize<T>` version then reads as the same trait with the value
moved out of `Self`. The example-code mirror compiles both levels.
[claude-opus-5-5] The section's closing paragraphs packed the
value-level dictionary, the instantiation order, a runtime-dictionary
aside on dynamic scoping, and the full account of the `E0275` cycle and
its workaround into three dense paragraphs, and moved between them
without transitions. They now conclude that CGP code could be desugared naturally
into dictionary-passing style, such as PolyMiniRust, with the context as
the root dictionary, and treat cycles as the one exception, leaving the
workaround's detail to the Rust's own proposals comparison.
[claude-opus-5-5] The zero-arity section compressed Capabilities using
Plain Traits into one paragraph of quotations, and it did not say how
his capabilities work, so the contrast with an incoherent selfless
trait was hard to follow. The section now explains, in its own words,
capabilities as bounds on a zero-sized `Env` type, selfless traits as a
way to drop that type, and the difference that matters here: his
capability traits carry no methods and hold by the target or a runtime
check, while an incoherent selfless trait carries methods whose
implementation the context chooses.
[claude-opus-5-5] The post linked each source and site page mostly at
its first mention, so a reader several screens later met Boxy's
incoherent traits, Nadrieril's dictionaries, scoped impls, or a CGP
construct with no link in view. Each such mention now links its
source, to the section that holds the example where one exists, and the
outline and summary link the sections they name.
[claude-opus-5-5] Phrases such as "the sections below", "the later
examples", "from earlier", and later mentions of named impls,
zero-arity traits, and scoped impls pointed at sections several screens
away without a link. Each now links the section it names.
[claude-opus-5-5] The post used its own term, zero-arity traits, beside
Nadrieril's selfless traits for the same shape, so readers met two
names for one idea. It now uses selfless traits throughout, with the
section, its links, and its example-code module renamed to match.
[claude-opus-5-5] A full natural-writing pass over the post found
pronouns without a clear referent, a background sentence carrying two
claims, a colon that pointed past the clause it explained, a run of
passive sentences after the `with` example, and a few awkward phrasings.
Each is revised without changing a claim or a link.
[claude-opus-5-5] The conclusion's last plans said CGP would simply
keep its library encoding if Incoherent Rust left out its features, and
proposed desugaring CGP into explicit proofs once nightly let programs
write them. It now offers to work with the compiler team where there is
an opportunity, states the risk to CGP if the features are left out,
and places the explicit-proof experiment in an experimental fork of
Rust that implements CGP's features in the compiler and desugars them
into the dictionary-passing intermediate representation.
[claude-opus-5-5] The post placed contexts and capabilities, a desugared
feature, inside the section on the context as a dictionary, and placed
selfless traits there too, though they are one of CGP's ideas for
Incoherent Rust and the abstract types built on them sat in that later
section. Contexts and capabilities now closes the desugaring section,
selfless traits now precede abstract types among the ideas, and the
cycle discussion has its own subsection that the earlier links point to.
The revised `Serialize<T>` in the incoherent-traits section carries a
comment saying it follows Boxy's simpler signature, and the example-code
modules follow the new heading order.

The front matter gains the `incoherent-rust-today` slug, the `deepdive`
tag, and a written description.
[claude-opus-5-5] After the reorganization, the desugaring section's
introduction named only Boxy's and Nadrieril's features though the
section now ends with Tyler Mandry's contexts and capabilities, the
dictionary example's "earlier ideas" no longer named which ones, and
the Scala comparison's "this kind of code" sat several paragraphs from
the code it meant. Each now names its subject, and the `touch` example's
three-claim sentence is split.
@soareschen soareschen changed the title [Blog post] Trying Incoherent Rust today with CGP [Blog post] Add Trying Incoherent Rust today with Context-Generic Programming Nov 28, 2026
[claude-opus-5-5] The post lacked the footnote that says how it was
made. It now ends with a line saying the author drafted it and an AI
agent revised it and checked its code and claims, linking the AI
disclosure's section on blog posts.
[claude-opus-5-5] The docs pages' provenance footers opened with "An AI
agent wrote this page", and several joined a second claim with ", and".
Each footer now reads "This page was written by an AI agent from the
CGP knowledge base", with each verification claim in its own sentence,
matching the blog post's line. The Contribute page drops its footer.
[claude-opus-5-5] The AI disclosure page ended with a section saying which
pages carry a provenance note and that the front page was the one
exception. The section is gone, so the page ends with its section on
responsibility.
[claude-opus-5-5] The comparisons index row and the Dynamic dispatch
opening still named C++ and multiple dispatch, which the page no longer
covers. The row now names Rust `dyn Trait` in their place, and the
opening names vtables in Java alone.
[claude-opus-5-5] The Dynamic dispatch comparison was titled "Dynamic
dispatch, dynamic typing, and prototypal inheritance", and the
incoherent-Rust post carried the date of its first revision. The page
is now titled "Dynamic dispatch", and the post's file carries its
publication date, with the snippet crates' references following.
[claude-opus-5-5] The Concepts pages that the incoherent-Rust post builds
on did not point to it. Each now lists the post in its Where to go next
section, linked to the section that develops the page's idea.
[claude-opus-5-5] The Concepts and comparison pages that the post builds
on mentioned it at most in a routing list. Each now cites the post's
matching section in the paragraph its argument develops, and Rust's own
proposals and Traits without coherence also route to it.
[claude-opus-5-5] Eight Concepts and comparison pages cited the post
although their subject is not coherence. Those pages return to their
earlier text, and only Bypassing coherence, Modularity hierarchy,
Rust's own proposals, and Traits without coherence cite it.
[claude-opus-5-5] Rewriting the docs footers left each changed page
without a final newline. Every such page ends with one again, the
post's struct-binding fixture names the heading the post now uses, and
the coherence page's routing item for the post says what CGP expresses.
[claude-opus-5-5] The citations of the post on four pages opened on the
post rather than the topic, joined claims with a trailing "which", or
left unclear what they translated. They now pick up the paragraph's
topic and name what the post shows.
@soareschen
soareschen merged commit dbe4f2a into main Nov 28, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant