Live data from Hacker News

Rust: “Explain GATs Like I'm 5 Years Old”

old.reddit.com

191–193 of 193 posts

Re: Rust: “Explain GATs Like I'm 5 Years Old”

#191

Earlier quoted context omitted.

> The entire point of GATs was to carve out a design space that solved peoples' problems without being so high-minded as monads and HKT and so on. High-minded or snobbish or whatever other deragotory words that one wants to use: the benefit of something like HKT is that it encompasses one thing that Rust now currently ends up catching up to by implementing dozens of “X with Y” (“generic const in associated lifetimes…

> Meanwhile a Haskell programmer might go years and never think about HKT as a feature. It’s just “kinds” without artificial-looking limitations. And yet, at the same time, Haskell has many, many extensions to enable certain features that would come for free in a dependently typed language, for example. I find Idris's type system easier to fit in my head, for example. There's always a next level of generality in whic…

> And yet, at the same time, Haskell has many, many extensions to enable certain features that would come for free in a dependently typed language, for example.

For sure.

In Rust’s case though it seemed that insiders were saying that HKT was more than the language needed, while now they keep running into limitations which necessitates patching up feature limitations. And patching up the language itself, not compiler extensions (maybe rustc is the only compiler that people use (?) but the updates are really to the language (in the abstract) itself).

But in any case, I’ve been told that I’m just talking out of my behind ;)

Re: Rust: “Explain GATs Like I'm 5 Years Old”

#193

Earlier quoted context omitted.

I can program in Scala and Haskell relatively easily. I still struggle with Rust's lifetime abstractions and things like this: impl LendingIterator for Map where I: LendingIterator, F: for Mapper >::Item>, { type Item = dyn for GivesItem >::Item>>::Output, >; fn next(&mut self) -> Option >::Item> { self.iter.next().map(&mut self.mapper) } } Haskell is so much easier.

I feel you, this is some particularly rough Rust code, combining quite a lot of stuff that I don't think I directly interacted with for my first few years. You have `for `, which I believe is probably the most complicated part of the language. That's a Higher Ranked Trait Bound, https://doc.rust-lang.org/nomicon/hrtb.html It just means "for all possible lifetimes 'a" as opposed to a single specific instance of a life…

Interesting, thank you!

For me, I am totally OK with remembering and resolving ambiguities in context (both Haskell and Scala are heavy with these). But when everything is explicit and visible all at once, I am stuck, because of information overload (I have ADHD, so there’s that).

Maybe Rust is just not for me.

Post reply on HN