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...
@contextgeneric.dev.bsky.social
A new modular paradigm for Rust. Project account managed by @maybevoid.com. More info at https://contextgeneric.dev/
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...
Through the extensible visitor pattern, you will see how to build a modular interpreter for a simple math expression language, complete with evaluation handlers that can be reused across different language versions.
10.07.2025 13:53 β π 0 π 0 π¬ 0 π 0I 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...
This also enables safe enum upcasting and downcasting, as well as modular builder and visitor patterns in Rust. Check out the blog post to find out more!
07.07.2025 14:00 β π 0 π 0 π¬ 0 π 0I'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.
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!
Announcing Hypershell: a modular, type-level DSL for shell-scripting in Rust, powered by Context-Generic Programming! contextgeneric.dev/blog/hypersh...
13.06.2025 23:19 β π 1 π 0 π¬ 0 π 2I 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-...
Also note that preset is an advanced concept in CGP that is yet to be formally introduced in our book. More updates will be coming very soon. But for now, you can check out the PR for a very high level overview of the changes: github.com/contextgener....
03.05.2025 20:31 β π 0 π 0 π¬ 0 π 0Now before you start wondering or getting disgusted, the inheritance in CGP is quite different from the classical inheritance in the OOP world. CGP presets are more like type-level dictionaries of generic mixins. So in a way, preset inheritance is sort of like extending type-level lookup tables.
03.05.2025 20:31 β π 0 π 0 π¬ 1 π 0It 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.
03.05.2025 20:31 β π 0 π 1 π¬ 1 π 0There are also many other advanced improvements, such as allowing PhantomData tags and generic implementation of field accessors using AsRef.
The PR covers high level overview of all changes. For detailed walk through, stay tuned for more blog posts and updates on the book.
This mainly improves use of CGP with idiomatic Rust code. Apparently, some readers pointed out about the aesthetic of getter methods returning &String instead of &str. This especially affects first impressions, when the hello world of CGP demonstrates the dependency injection of string fields.
23.03.2025 16:45 β π 2 π 0 π¬ 1 π 0A 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<T> fields.
github.com/contextgener...
Here is the original article: programming-journal.org/2025/10/15/
12.03.2025 10:27 β π 1 π 0 π¬ 0 π 0A 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...
We are in the progress of writing a full blog post detailing all new features, as well as updating the CGP Patterns book to include the new features. Hopefully this will all be done in a few more weekends!
09.03.2025 21:46 β π 1 π 0 π¬ 0 π 0CGP 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.
Yup, you can think of it that way. Though if we just remove coherence alone, there are other problems popping up that makes programming in it less ergonomic. So CGP also has other techniques that work together *with* coherence to make it easy to choose and wire up different blanket impls.
12.01.2025 13:19 β π 0 π 0 π¬ 0 π 0As an example, you can't write a generic `Serialize` implementation that works for any type that implements `Display`. But you can do that with CGP, if there a corresponding providder trait like `SerializerProvider`/
12.01.2025 10:01 β π 0 π 0 π¬ 1 π 0Good question! The problem is it is not possible to define multiple context-generic implementations of a trait in Rust, due to limitations of the trait system. CGP is a workaround of that limitation.
In CGP we make heavy use of trait-only crates, such as cgp-error, perhaps more than normal Rust.
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
11.01.2025 23:53 β π 3 π 2 π¬ 1 π 1I will submit this onto social media tomorrow, as with the news on Rust v1.84 release and new issue for This Week in Rust, it might be too noisy to gain attention at the moment.
09.01.2025 20:50 β π 0 π 0 π¬ 0 π 0We 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-...
I will write a full blog post and release note tomorrow. For now, do check out the revised chapters for CGP Patterns:
patterns.contextgeneric.dev/error-handli...
patterns.contextgeneric.dev/field-access...
#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.
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
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 handling sure is a complex topic to cover! There is probably one sub-chapter left, before we can leave the topic of error handling and move on to other #CGP topics!
02.01.2025 23:08 β π 0 π 0 π¬ 0 π 0With the decoupling, we can produce highly detailed error reports externally, but the core implementation would not need to be tightly coupled with any of such error handling logic.
02.01.2025 23:08 β π 0 π 0 π¬ 1 π 0