Zero-Cost 'Tagless Final' in Rust with GADT-style Enums

17 points by abhin4v 18 hours ago on lobsters | 8 comments

anex9d | 17 hours ago

I know this article is exploratory and I think it’s great. As an aside, and as someone who learned haskell first and found my way to rust, articles like this make me wish there were some happy medium between the two languages. The rust here looks cursed, and the haskell is so much cleaner, but I shy away from haskell because I personally find its laziness difficult to reason about. Is OCaml that middle ground?

alper | 16 hours ago

The rust here looks cursed

No they say it's:

A Simple eval

For whoever thinks this is simple. The problem with strong type systems is that somebody will start doing this stuff and then these practices will bleed into the ecosystem and you'll have to deal with it.

refi64 | 16 hours ago

The problem with strong type systems is that somebody will start doing this stuff and then these practices will bleed into the ecosystem and you'll have to deal with it.

You could say this about any sufficiently advanced language feature, no? Even Go can't entirely escape it, "the problem with reflection is that somebody will start overusing it and the ecosystem will have slow reflection-heavy libraries" and suddenly you have GORM. "The problem with pointers [...]" and suddenly you have C libraries built on sketchy pointer arithmetic.

(Also, I think the terminology is a bit off? "Strong type system" would include e.g. Go or arguably Python.)

There's an infamous copypasta about this, but for Go's generics: https://news.ycombinator.com/item?id=20023314

alper | 14 hours ago

C libraries built on sketchy pointer arithmetic

Yes, you can't escape it entirely and that's where the culture comes in which has to police and shun things that are considered uncouth. I think Python for instance does that quite well.

Strong type system

I'm not sure how else to call it.

There are more than 5 meanings of “strong type system”, so rather than using that phrase you should describe the specific features you want to talk about https://dotat.at/@/2025-08-28-strongly-typed.html

alper | 11 hours ago

That's cool. What do we call it? Fancily typed?

gasche | 16 hours ago

My impression (speaking from: OCaml expert, read-only knowledge of Haskell and Rust) is that the specific annotation noise you see in this post would be gone in OCaml, thanks to more aggressive type inference. But some other things you like from Haskell that rely heavily on typeclasses (say: mtl-style monad stacks) will be very painful in OCaml as well. So I think that for some usage patterns the answer will be "yes indeed OCaml is a pragmatic cousin you would appreciate", but in some other aspects the Haskell type system cannot be replaced.

(It used to be the case that abstracting over higher-kinded types, eg. abstracting on a monad parameter, would not translate well to OCaml, but recent versions added "module-dependent functions" which do provide a convenient way to do it; so at least this aspect is now fine!)