Skip to content
Tech News
← Back to articles

Torturing Rustc by Emulating HKTs

read original more articles
Why This Matters

This article highlights the ongoing challenges and innovations in Rust's type system, particularly around higher-kinded types (HKTs) and generic programming. Understanding these developments is crucial for developers aiming to write more flexible and abstract code, pushing the boundaries of Rust's capabilities and influencing future language features.

Key Takeaways

Reading time: 32 min read

Uh oh! We forgot something. That is…

So uh let’s add that to our Ast struct.

Of course, since this is my project and I wanted to be a little bit silly, I went ahead and abstract this like a Java Enterprise Software Engineer but in an alternative universe where everything is Haskell.

I realized that I wanted to add a way to include spans when I wanted or not. So here’s something I cooked up:

So I wrote up an Ast enum for a basic calculator to start:

On the 28th day of February of the year 2026, I was attempting to start writing an FP scripting language for fun.

Me: Who are you?

Me: I love coding and fucking around. Surely the universe won’t explode in the future?

Anyways, given the newfound Wrap superpower, let’s rewrite this. On second thought, wrapping every field in W::Wrapper is a stupid idea. Should have been just the Ast .

... continue reading