There are thousands of words of prose to describe it between this and the shell-scripting post, and a lot of code-level seams and abstractions introduced in the snippets. Yet I still can't tell you why I should want to do the new things that this code style would make possible for me to do.
I also probably wouldn't enjoy trying to onboard a new contributor to a hypothetical project using this style, no matter how experienced with Rust they might be. DSLs, which I would consider CGP to be one, have a pretty high friction rate if they haven't become dominant/widespread.
maybevoid•4h ago
For those of you coming from functional languages, this development effectively brings the power of datatype-generic programming, structural typing, row polymorphism and polymorphic variants to Rust. These are advanced type system features commonly found in languages like Haskell, PureScript and OCaml, and their availability in CGP represents a major leap in what is possible with the type system in Rust.
If you're new to the concept, extensible data types allow us to read from, construct, and extract data from a generic struct or enum without needing to know its concrete type definition. This opens the door to powerful design patterns, such as building generic builders or visitors that can operate flexibly over a wide range of data structures.
In the first post of this new blog series, I walk through a simple example that shows how to use extensible builders to construct an application context in a modular way.
I’d love to hear what you think — especially whether the approach feels practical or insightful for your own work. I’ll be sharing more updates over the next few days, so stay tuned!