Skip to main content

6 posts tagged with "Deep Dive"

In-depth articles and analyses

View All Tags

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.

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.

Programming Extensible Data Types in Rust with CGP - Part 2: Modular Interpreters and Extensible Visitors

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

This post's code predates the current design of CGP. The interpreter it develops is documented as it is now in the expression pages of the Projects section, one page per context, and Extensible variants explains the current design of the feature.

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

In this second part of the series, we will explore the use of extensible variants, by examining how it can be used in an extensible visitor pattern to build a modular interpreter for a toy math expression language.

Programming Extensible Data Types in Rust with CGP - Part 1: Modular App Construction and Extensible Builders

· 37 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 application builder this post develops is one of the cgp-examples crates in the Projects section.

I’m excited to announce the release of CGP v0.4.2, a major milestone that significantly expands the expressive power of generic programming in Rust. With this release, CGP introduces full support for extensible records and variants, unlocking a range of new capabilities for developers working with highly modular and reusable code.

Extensible records and variants allow developers to write code that operates on any struct containing specific fields or any enum containing specific variants, without needing their concrete definition. This makes it possible to write truly generic and flexible logic that is decoupled from rigid type definitions.

Hypershell: A Type-Level DSL for Shell-Scripting in Rust

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

This post describes Hypershell as it was when the post was published, and its code predates the current design. The Hypershell pages in the Projects section document it as it is now, with each example program walked through as a short tutorial.

I am thrilled to introduce Hypershell, a modular, type-level domain-specific language (DSL) for writing shell-script-like programs in Rust. Hypershell is powered by context-generic programming (CGP), which makes it possible for users to extend or modify both the language syntax and semantics.