Skip to main content
Soares Chen
Creator of Context-Generic Programming
View all authors

CGP v0.8.0 - cargo-cgp, new documentation, and namespaces

· 43 min read
Soares Chen
Creator of Context-Generic Programming

Context-Generic Programming (CGP) v0.8.0 is out! This release is about making CGP easier to learn and maintain. It introduces cargo-cgp, a new tool for one of CGP's longest-standing problems: compile errors that describe the code the macros generated rather than the code you wrote. cargo-cgp explains those errors in your terms. When a provider needs a field your type lacks, for example, it can tell you which field to add, and the expanded documentation explains why the provider needs it. Later, as your application grows, the new namespaces let you choose the providers for a whole group of components in one wiring entry.

How to stop fighting with coherence and start writing context-generic trait impls - RustLab 2025 transcript

· 32 min read
Soares Chen
Creator of Context-Generic Programming
note

The cgp-serde library this talk uses as its demonstration is documented as it is now in the Projects section, including the two-application demo, and Coherence explains the idea the talk presents.

This blog post contains the slides and transcript for my presentation of Context-Generic Programming at RustLab 2025.

You can also read the PDF slides or watch the video recording of my presentation on YouTube.

Supercharge Rust functions with implicit arguments using CGP v0.7.0

· 17 min read
Soares Chen
Creator of Context-Generic Programming

CGP v0.7.0 has been released, bringing a major expansion to the CGP macro toolkit. The centerpiece of this release is a suite of new annotations — #[cgp_fn], #[implicit], #[uses], #[extend], #[use_provider], and #[use_type] — that let you write context-generic code in plain function syntax with dramatically less boilerplate than before.

CGP v0.6.1 Release: Improving Ergonomics and Debugging

· 9 min read
Soares Chen
Creator of Context-Generic Programming

We're excited to announce the release of cgp v0.6.1, which brings several quality-of-life improvements to Context-Generic Programming in Rust. This release focuses on making CGP more accessible to developers new to the paradigm while also providing better debugging and verification tools for complex provider setups.

The changes in this release reflect our commitment to lowering the barrier to entry for CGP, while maintaining the power and flexibility that make it such a compelling approach to modular Rust code. Whether you're an experienced CGP user or just getting started, we believe you'll find these improvements meaningful.

Announcing cgp-serde: A modular serialization library for Serde powered by CGP

· 36 min read
Soares Chen
Creator of Context-Generic Programming
note

This post describes cgp-serde as it was when the post was published, and its code predates the current design. The cgp-serde pages in the Projects section document it as it is now, with its examples walked through as short tutorials and a reference page for each provider.

I am excited to announce the release of cgp-serde, a modular serialization library for Serde that leverages the power of Context-Generic Programming (CGP).

In short, cgp-serde extends Serde’s original Serialize and Deserialize traits with CGP, making it possible to write overlapping or orphaned implementations of these traits and thus bypass the standard Rust coherence restrictions.

Furthermore, cgp-serde allows us to leverage the powerful context and capabilities concepts in stable Rust today. This unlocks the ability to write context-dependent implementations of Deserialize, such as one that uses an arena allocator to deserialize a 'a T value, a concept detailed in the proposal article.

CGP v0.5.0 Release: Auto dispatchers, extensible datatype improvements, monadic computation, RTN emulation, modular serde, and more

· 26 min read
Soares Chen
Creator of Context-Generic Programming

CGP v0.5.0 has been released, bringing a range of new features and some breaking changes as part of the ongoing effort toward stabilization. This version introduces several improvements to make CGP more practical, expressive, and easier to use in real-world Rust projects.

The highlights of this major release are summarized below. Also check out the changelog for the full list of changes.

Programming Extensible Data Types in Rust with CGP - Part 4: Implementing Extensible Variants

· 62 min read
Soares Chen
Creator of Context-Generic Programming
note

This post's code predates the current design of CGP. Extensible variants explains the current design of the feature, the reference documents the extraction and casting traits this post walks through, and the expression pages show the feature in a running interpreter.

This is the fourth part of the blog series on Programming Extensible Data Types in Rust with CGP. You can read the first, second and third parts here.

In the third part of the series, Implementing Extensible Records, we have walked through the internal implementation of extensible records, and learned about concepts such as partial records and builder dispatchers.

In this final fourth part of the series, we will have the same walk through for the internal implementation details for extensible variants.

Programming Extensible Data Types in Rust with CGP - Part 3: Implementing Extensible Records

· 41 min read
Soares Chen
Creator of Context-Generic Programming
note

This post's code predates the current design of CGP. Extensible records explains the current design of the feature, and the reference documents each of the traits this post walks through.

This is the third part of the blog series on Programming Extensible Data Types in Rust with CGP. You can read the first and second parts here.

At this point, you’ve likely seen how these patterns can make real-world applications more modular and maintainable. If these examples have convinced you of CGP’s practical value, that’s great. But if you still feel the examples are not grounded enough in production use cases, you are welcome to pause here and revisit CGP later.

The next 2 parts of the series are aimed at readers who want to go deeper — those interested in how CGP implements extensible data types under the hood and who might even want to contribute to CGP itself by helping to build the real-world examples you’re looking for.

We will first explore the implementation of extensible records in this part, followed by the implementation of extensible variants in the coming Part 4.