Soares Chen

Soares Chen

@maybevoid.com

Rust Nerd ∘ Creator of Context-Generic Programming @contextgeneric.dev ∘ Interested in Haskell, functional programming, type theory, category theory, programming language theory ∘ https://maybevoid.com ∘ https://contextgeneric.dev

155 followers227 following107 posts

In short, cgp-serde extends Serde’s original Serialize and Deserialize traits with CGP, making it possible to write overlapping or orphaned implementations of these traits and thus bypass the standard Rust coherence restrictions.

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, and more. contextgeneric.dev/blog/v0-5-0-...

contextgeneric.devCGP v0.5.0 Release - Auto dispatchers, extensible datatype improvements, monadic computation, RTN emulation, modular serde, and more | Context-Generic Programming

My observation of ML frameworks from the POV of a functional programmer: PyTorch tensors are actually some kind of monad, with the dimensions being the "type" of the contained values.

If you treat the tensor monad as fully abstract, you then pretty much get free monad and algebraic effects. You can then do different kinds of abstract interpretation on the free monad, and do things other than the actual computation, such as compiling it to various optimized compute kernels.

Soares Chen reposted

Today’s my last day at AWS working on the Rust compiler. Unfortunately, back in July I received notice that I had to choose between moving to Boston from NYC, or leaving the company due to RTO policy. I unfortunately couldn’t abandon the city I plan on being my long term home.

Soares Chen reposted

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

Learn about how to build modular interpreters and visitors in Rust using CGP!

Context-Generic Programming@contextgeneric.dev

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...

Surprisingly, it turns out CGP already supports fully monadic computation in Rust! It is just that the CGP monads are in the form `a -> m b` instead of the usual `m a`.

View full thread

Actually, the monadic form in CGP is more than just (a -> m b) - it is more like (Ctx => a -> m b). That makes it much more powerful and practical for monadic computation, because we can do dependency injection with the implicit constraints!

CGP also has the lift operator, called `Promote`, to lift the `m` in `(Ctx => a -> m b)`. With that, you can probably see how we can support everything essential about monads with CGP in Rust!

Surprisingly, it turns out CGP already supports fully monadic computation in Rust! It is just that the CGP monads are in the form `a -> m b` instead of the usual `m a`.

Also, the composition operator for CGP monads is not (>>=) or (>>), but rather it is just pipe (|) :: (a -> m b) -> (b -> m c) -> (a -> m c). Despite that, pipe is probably much as powerful as bind, just with different syntax.

CGP v0.4.2 has been released, with brand new support for extensible records and variants. Check out the blog post to find out more! contextgeneric.dev/blog/extensi...

contextgeneric.devProgramming Extensible Data Types in Rust with CGP - Part 1: Highlights and Extensible Records Demo | Context-Generic Programming
Context-Generic Programming@contextgeneric.dev

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.

Soares Chen reposted

Howdy all. I'm unfortunately not going to be with my employer for much longer due to team relocation. If anyone has any info on roles that would allow me to continue my Rust compiler work (in New York City), they'd be greatly appreciated.

Oh wow, since when did Firefox implement native integration with all major LLMs like ChatGPT? Did they get any funding from that integration? How come I never seen any such news or discussion on Hacker News?

Finally I can get back to hacking the core CGP implementation! This time with a new CGP builder pattern for constructing Rust structs!

Context-Generic Programming@contextgeneric.dev

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!

At least this is the first time I'm able to break the compiler with sufficiently "simple" applications. Might be time for me to finally get my hand dirty on Rustc.

I have created Hypershell as a proof of concept to showcase how CGP can be used to build highly modular and extensible DSLs, with the DSL programs expressed as Rust types!

Context-Generic Programming@contextgeneric.dev

Announcing Hypershell: a modular, type-level DSL for shell-scripting in Rust, powered by Context-Generic Programming! contextgeneric.dev/blog/hypersh...

The vibe coding debate focused mostly on beginners who code with AI without understanding programming fundamentals, and experts who bash that the code generated by AI is incorrect. But why not we *train* the AI to be good at teaching beginners on *hard* topics, e.g. Rust and functional programming?

View full thread

As for the future where AI becomes smarter than average humans and take over programming jobs? I don't like that kind of future, but I also think that it is futile for me to personally fight against that.

The vibe coding debate focused mostly on beginners who code with AI without understanding programming fundamentals, and experts who bash that the code generated by AI is incorrect. But why not we *train* the AI to be good at teaching beginners on *hard* topics, e.g. Rust and functional programming?

View full thread

Of course, there is always a risk of backfiring that some people would just acknowledge that AI is smarter than them and let it do all the jobs. But my hope is that at least there will also be a growing number of people who are more *willing* to learn hard topics thanks to the AI tutors.

So I guess I will probably fight for a future where people no longer complain that things are too difficult for them to learn, because there is always an AI companion there to teach them everything they need.

The vibe coding debate focused mostly on beginners who code with AI without understanding programming fundamentals, and experts who bash that the code generated by AI is incorrect. But why not we *train* the AI to be good at teaching beginners on *hard* topics, e.g. Rust and functional programming?

View full thread

So I would rather be in a world where we can confidently tell beginners that: "Look, Rust is not *that* hard if the AI is smart enough to learn it and *teach* you all essential concepts".

Beginners should have two choices that either you bite the bullet and learn Rust through either humans or the AI tutor, or you'd be essentially acknowledging that the AI is *smarter* than you if you still find it to be too hard to learn.

The vibe coding debate focused mostly on beginners who code with AI without understanding programming fundamentals, and experts who bash that the code generated by AI is incorrect. But why not we *train* the AI to be good at teaching beginners on *hard* topics, e.g. Rust and functional programming?

View full thread

I think AI could be a great tutor on topics that people claim to be too hard to learn, such as programming in Rust or CGP. Granted, the AI's understanding of the advanced topics are not perfect, but this is where we human experts can step in to help train the AI to better train the beginners.

I don't like the dilemma of the fact that if the AI is good enough at teaching programming, then it is also good enough to take over the programming job. But I also don't like seeing people complaining that a language like Rust is bad because it is "too hard to learn".

The vibe coding debate focused mostly on beginners who code with AI without understanding programming fundamentals, and experts who bash that the code generated by AI is incorrect. But why not we *train* the AI to be good at teaching beginners on *hard* topics, e.g. Rust and functional programming?

I am thinking of using AI to figure out which concepts in @contextgeneric.dev are hard to understand, by asking it to read the documentation and explain the code base. If the AI cannot explain the concepts clearly, I would add new documentation until all the misunderstanding are clarified.

Here are some sneak previews of what I have been working on for the past 2 weeks. Hypershell is a compile-time DSL for writing shell-script-like programs as Rust types. It is powered by context-generic programming, and is highly customizable and extensible!

Soares Chen reposted

Soares Chen reposted

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.

Soares Chen reposted