Context-Generic Programming
banner
contextgeneric.dev
Context-Generic Programming
@contextgeneric.dev
A new modular paradigm for Rust. Project account managed by @maybevoid.com. More info at https://contextgeneric.dev/
Pinned
I am excited to share the second part of my blog series on Extensible Data Types with CGP. This post dives into how CGP leverages extensible variants to elegantly solve the expression problem.

contextgeneric.dev/blog/extensi...
Programming Extensible Data Types in Rust with CGP - Part 2: Modular Interpreters and Extensible Visitors | Context-Generic Programming
contextgeneric.dev
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).

contextgeneric.dev/blog/cgp-ser...
Announcing cgp-serde: A modular serialization library for Serde powered by CGP | Context-Generic Programming
contextgeneric.dev
November 3, 2025 at 1:15 PM
I’m excited to announce the release of CGP v0.6.0!
This version introduces major ergonomic improvements that make provider and context implementations simpler and more intuitive to write. contextgeneric.dev/blog/v0-6-0-...
CGP v0.6.0 Release - Major ergonomic improvements for provider and context implementations | Context-Generic Programming
contextgeneric.dev
October 26, 2025 at 11:56 AM
I am thrilled to announce the release of CGP v0.5.0! This new release includes many exciting features and improvements, including auto dispatchers, extensible datatype improvements, monadic computation, emulation of RTN, sneak preview of cgp-serde. #RustLang

contextgeneric.dev/blog/v0-5-0-...
CGP v0.5.0 Release - Auto dispatchers, extensible datatype improvements, monadic computation, RTN emulation, modular serde, and more | Context-Generic Programming
contextgeneric.dev
October 12, 2025 at 2:46 PM
I will be presenting at RustLab on how to stop fighting with coherence and start writing context-generic programs with CGP. Use the discount code SP20FR to attend the conference with 20% discount!
Tired of fighting Rust’s coherence rules?
S@maybevoid.com introduces Context-Generic Programming: a new way to write flexible trait impls without breaking the rules.
🧩 How to Stop Fighting with Coherence and Start Writing Context-Generic Trait Impls
#rustlang #rustlab2025
August 26, 2025 at 12:59 PM
Reposted by Context-Generic Programming
Tired of fighting Rust’s coherence rules?
S@maybevoid.com introduces Context-Generic Programming: a new way to write flexible trait impls without breaking the rules.
🧩 How to Stop Fighting with Coherence and Start Writing Context-Generic Trait Impls
#rustlang #rustlab2025
August 26, 2025 at 11:30 AM
Reposted by Context-Generic Programming
I will be presenting at @rustlab.it on how to stop fighting with coherence and start writing context-generic programs with @contextgeneric.dev. Use the discount code SP20FR to attend the conference with 20% discount!

rustlab.it/talks/how-to...
RustLab | How to Stop Fighting with Coherence and Start Writing Context-Generic Trait Impls
Soares Chen at RustLab 2025
rustlab.it
August 23, 2025 at 10:51 AM
The third and fourth parts of Extensible Data Types for Rust - the design and implementation of extensible records and variants - has been published!

contextgeneric.dev/blog/extensi...
contextgeneric.dev/blog/extensi...
Programming Extensible Data Types in Rust with CGP - Part 3: Implementing Extensible Records | Context-Generic Programming
contextgeneric.dev
August 5, 2025 at 3:43 PM
I am excited to share the second part of my blog series on Extensible Data Types with CGP. This post dives into how CGP leverages extensible variants to elegantly solve the expression problem.

contextgeneric.dev/blog/extensi...
Programming Extensible Data Types in Rust with CGP - Part 2: Modular Interpreters and Extensible Visitors | Context-Generic Programming
contextgeneric.dev
July 10, 2025 at 1:53 PM
I'm excited to share the release of CGP v0.4.2, with new support for extensible records and variants! contextgeneric.dev/blog/extensi...

In short extensible data types allows us to read, construct, and deconstruct a *generic* struct or enum without needing access to the concrete type.
Programming Extensible Data Types in Rust with CGP - Part 1: Highlights and Extensible Records Demo | Context-Generic Programming
contextgeneric.dev
July 7, 2025 at 2:00 PM
Now that Hypershell is finally published, it is finally time to go back to working on the core CGP implementation and add new features.

The new CGP builder pattern is being developed pretty smoothly. Here is a snippet Rust code on the test code and macro expansion!
June 17, 2025 at 8:50 PM
Announcing Hypershell: a modular, type-level DSL for shell-scripting in Rust, powered by Context-Generic Programming! contextgeneric.dev/blog/hypersh...
Hypershell: A Type-Level DSL for Shell-Scripting in Rust | Context-Generic Programming
contextgeneric.dev
June 13, 2025 at 11:19 PM
I am excited to share about the new release of #CGP v0.4.0! This update solves a major challenge in debugging CGP-related errors in Rust, simplifies the developer experience with new macros, and added new features such as presets and datatype-generic programming.

contextgeneric.dev/blog/v0-4-0-...
CGP v0.4.0 is Here: Unlocking Easier Debugging, Extensible Presets, and More! | Context-Generic Programming
CGP v0.4.0 is officially released, bringing transformative improvements! Experience dramatically easier debugging, powerful new features, and a smoother developer journey for modular Rust programming.
contextgeneric.dev
May 9, 2025 at 3:05 PM
It is now possible to do OOP-like inheritance at the type-level in #RustLang using #CGP! Our latest PR brings significant improvements to defining and using presets in CGP, with support for multiple-inheritance, and override mechanism to overcome the diamond inheritance problem.
May 3, 2025 at 8:31 PM
A lot of new features have been added to the `#[cgp_getter]` macro! For the basic use cases, you can now define getter methods that return &str or Option<&T>, and the macro will generate getter implementations that read from String or Option fields.

github.com/contextgener...
Refactoring and Improvements on `#[cgp_getter]` by soareschen · Pull Request #81 · contextgeneric/cgp
Summary This PR brings several quality of life improvements on the proc macros #[cgp_getter] and #[cgp_auto_getter], allowing them to support more general getter interfaces to be defined. Specializ...
github.com
March 23, 2025 at 4:45 PM
A great article that gives an overview of the coherence problem in typeclasses/traits has been surfaced on Hacker News. I am trying to take the opportunity to pitch about CGP and how it helps solve the given coherence problems.

Help give me an upvote here: news.ycombinator.com/item?id=4334...
Shameless plug: I am working on a solution in Rust that solves the coherence pro... | Hacker News
news.ycombinator.com
March 12, 2025 at 10:27 AM
CGP now has a new logo! The website has been updated with the new logo and color theme: contextgeneric.dev

There are many exciting features in the upcoming v0.4.0 release. In particular, CGP now shows much more informative compile errors that makes it much easier to debug CGP code.
March 9, 2025 at 9:46 PM
You should still care about modularity, even if you don't write modular code yourself. Because modularity allows you to reuse modular code written by *others*, so that you can write much less non-modular code yourself. #CGP #RustLang
January 11, 2025 at 11:53 PM
We have just published an update blog post on the release of #CGP v0.3.0, along with new book chapters! #RustLang

contextgeneric.dev/blog/v0-3-0-...
CGP Updates: v0.3.0 Release and New Chapters | Context-Generic Programming
We’re excited to announce the release of v0.3.0 of the cgp crate, along with several new chapters of the CGP Patterns book!
contextgeneric.dev
January 9, 2025 at 8:45 PM
#CGP v0.3.0 has been released! This release includes a lot of QoL improvements, including the new `cgp_type!` and `#[cgp_getter]` macros, and the new `cgp-error-anyhow` crate. #RustLang

The CGP Patterns book has also been updated with significant revision on based on the new features.
January 8, 2025 at 9:32 PM
A new chapter for #CGP Patterns have been released! patterns.contextgeneric.dev/field-access...

This time, we go into deep dive various ways of defining and implementing field accessors using CGP, the HasField trait, and context-generic accessor providers. #RustLang
Field Accessors - Context-Generic Programming Patterns (DRAFT)
patterns.contextgeneric.dev
January 6, 2025 at 5:09 PM
Another new chapter for #CGP Patterns have been released! patterns.contextgeneric.dev/error-wrappi...

This time, we walk through an example config loader provider that reads a config file and parses the content as JSON, and how to wrap around #RustLang errors like std::io::Error with more details.
Error Wrapping - Context-Generic Programming Patterns (DRAFT)
patterns.contextgeneric.dev
January 5, 2025 at 5:47 PM
Another new chapter for #CGP Patterns has been released! This time on error reporting: patterns.contextgeneric.dev/error-report...

The chapter walks through how we can decouple #RustLang code that produce errors from code that handles/report errors.
Error Reporting - Context-Generic Programming Patterns (DRAFT)
patterns.contextgeneric.dev
January 2, 2025 at 11:08 PM
Happy new year! Another new chapter for #CGP #RustLang has been released: Error handling using delegated error raisers - patterns.contextgeneric.dev/delegated-er...

This chapter dives into some advanced techniques in CGP to make it so that we can declaratively handle different source error types.
Delegated Error Raiser - Context-Generic Programming Patterns (DRAFT)
patterns.contextgeneric.dev
January 1, 2025 at 11:06 PM
New chapter released for #CGP Patterns: Error Handling. patterns.contextgeneric.dev/error-handli...

The introduction to error handling in CGP is very important, as it is very different from how error handling is typically done in #RustLang.
Error Handling - Context-Generic Programming Patterns (DRAFT)
patterns.contextgeneric.dev
December 31, 2024 at 10:37 PM
New chapter for CGP Patterns has been released! With the introduction of associated types, we can now walk through more practical examples of using CGP to validate authentication tokens using abstract time and auth token types.

patterns.contextgeneric.dev/associated-t...
Associated Types - Context-Generic Programming Patterns (DRAFT)
patterns.contextgeneric.dev
December 28, 2024 at 10:00 PM