Skip to content

Commit de0337b

Browse files
authored
Merge pull request #8 from contextgeneric/extensible-datatypes-part-3
Publish part 3 of Extensible Data Types
2 parents a973442 + 677c24a commit de0337b

5 files changed

+101
-50
lines changed

content/_index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ Read the blog series **Programming Extensible Data Types in Rust with CGP** for
1616

1717
- [**Part 1: Modular App Construction and Extensible Builders**](/blog/extensible-datatypes-part-1/)
1818
- [**Part 2: Modular Interpreters and Extensible Visitors**](/blog/extensible-datatypes-part-2/)
19+
- [**Part 3: Implementing Extensible Records**](/blog/extensible-datatypes-part-3/)
1920

2021
# Overview
2122

content/blog/2025-07-07-extensible-datatypes-part-1.md

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,12 @@ This article is the first in a five-part series exploring the examples and imple
3434

3535
**Part 1: Modular App Construction and Extensible Builders** (this post) – In this introductory part, we present a high-level overview of the key features enabled by extensible data types. We then dive into a hands-on demonstration showing how extensible records can be used to build and compose modular builders for real-world applications.
3636

37-
[**Part 2: Modular Interpreters and Extensible Visitors**](/blog/extensible-datatypes-part-2/) – This part continues the demonstration by introducing extensible variants. We use them to address the [**expression problem**](https://en.wikipedia.org/wiki/Expression_problem), implementing a set of reusable interpreter components for a small toy language.
37+
[**Part 2: Modular Interpreters and Extensible Visitors**](/blog/extensible-datatypes-part-2) – This part continues the demonstration by introducing extensible variants. We use them to address the [**expression problem**](https://en.wikipedia.org/wiki/Expression_problem), implementing a set of reusable interpreter components for a small toy language.
3838

39-
**Part 3: Implementing Extensible Records** – Here, we walk through the internal mechanics behind extensible records. We show how CGP supports the modular builder pattern demonstrated in Part 1 through its underlying type and trait machinery.
39+
[**Part 3: Implementing Extensible Records**](/blog/extensible-datatypes-part-3) – Here, we walk through the internal mechanics behind extensible records. We show how CGP supports the modular builder pattern demonstrated in Part 1 through its underlying type and trait machinery.
4040

4141
**Part 4: Implementing Extensible Variants** – This part mirrors Part 3, but for extensible variants. We examine how extensible variants are implemented, and compare the differences and similarities between extensible records and variants.
4242

43-
**Part 5: Handler Hierarchy and Conclusion** – In the final part, we explore how extensible data types integrate into the broader CGP handler hierarchy — from `Computer` to `Handler` — to support all forms of programs from pure computations to async I/O with failures. We conclude the series with a summary of key takeaways and the design philosophy behind CGP.
44-
4543
# Feature Highlighs
4644

4745
## Safe Enum Upcasting
@@ -1066,8 +1064,6 @@ This approach dramatically simplifies configuration management, promotes code re
10661064

10671065
In [Part 2 of this series, **Modular Interpreters and Extensible Visitors**](/blog/extensible-datatypes-part-2/), we’ll shift gears to look at **extensible variants**, where CGP tackles the expression problem with a modular visitor pattern. If you've ever wanted to define interpreters, pattern match over generic enums, or evolve your data types without breaking existing logic — you won’t want to miss what’s coming next.
10681066

1069-
Stay tuned!
1070-
10711067
## Hire Me
10721068

10731069
P.S. Btw, [I am available for hire](/hire)!

content/blog/2025-07-09-extensible-datatypes-part-2.md

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
title = "Programming Extensible Data Types in Rust with CGP - Part 2: Modular Interpreters and Extensible Visitors"
44

5-
description = ""
6-
75
authors = ["Soares Chen"]
86

97
+++
@@ -12,7 +10,7 @@ Discuss on [Reddit](https://www.reddit.com/r/rust/comments/1lvgyre/building_modu
1210

1311
# Recap
1412

15-
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](/blog/extensible-datatypes-part-1).
13+
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](/blog/extensible-datatypes-part-1).
1614

1715
As a recap, we have covered the new release of [**CGP v0.4.2**](https://github.com/contextgeneric/cgp/releases/tag/v0.4.2) which now supports the use of **extensible records and variants**, allowing developers to write code that operates on *any struct containing specific fields* or *any enum containing specific variants*, without needing their concrete definition.
1816

@@ -26,12 +24,10 @@ In this second part of the series, we will explore the use of **extensible varia
2624

2725
**Part 2: Modular Interpreters and Extensible Visitors** (this post) – This part continues the demonstration by introducing extensible variants. We use them to address the [**expression problem**](https://en.wikipedia.org/wiki/Expression_problem), implementing a set of reusable interpreter components for a small toy language.
2826

29-
**Part 3: Implementing Extensible Records** – Here, we walk through the internal mechanics behind extensible records. We show how CGP supports the modular builder pattern demonstrated in Part 1 through its underlying type and trait machinery.
27+
[**Part 3: Implementing Extensible Records**](/blog/extensible-datatypes-part-3) – Here, we walk through the internal mechanics behind extensible records. We show how CGP supports the modular builder pattern demonstrated in Part 1 through its underlying type and trait machinery.
3028

3129
**Part 4: Implementing Extensible Variants** – This part mirrors Part 3, but for extensible variants. We examine how extensible variants are implemented, and compare the differences and similarities between extensible records and variants.
3230

33-
**Part 5: Handler Hierarchy and Conclusion** – In the final part, we explore how extensible data types integrate into the broader CGP handler hierarchy — from `Computer` to `Handler` — to support all forms of programs from pure computations to async I/O with failures. We conclude the series with a summary of key takeaways and the design philosophy behind CGP.
34-
3531
# Extending the Visitor Pattern
3632

3733
Earlier, we explored how CGP uses the extensible builder pattern to enable modular construction of context structs. In this article, we will see how a similar approach can be applied to context **enums**, allowing each variant to be destructured and handled by a flexible, composable set of handlers.
@@ -907,9 +903,8 @@ Rather than tying our logic to rigid enums or bloated visitor traits, we’ve be
907903

908904
This is more than a workaround for the expression problem — it’s a foundational shift in how we think about data structures and operations in Rust. With CGP, you no longer need to trade off between extensibility and type safety. You can add new variants without touching existing code, and build interpreters or transformers that evolve organically with your domain.
909905

910-
In Part 3 of this series, **Implementing Extensible Records**, we will dive into the *underlying* implementation details of **extensible records**, and how the extensible builder pattern is built on top of it. We will cover the concepts of **partial records**, and the use of traits such as `BuildField` and `FinalizeField` to represent *row constraints*.
906+
In [Part 3 of this series, **Implementing Extensible Records**](/blog/extensible-datatypes-part-3), we will dive into the *underlying* implementation details of **extensible records**, and how the extensible builder pattern is built on top of it. We will cover the concepts of **partial records**, and the use of traits such as `BuildField` and `FinalizeField` to represent *row constraints*.
911907

912-
Stay tuned!
913908

914909
## Hire Me
915910

0 commit comments

Comments
 (0)