News for hackers. Stuff that matters.
Re:Improving Interoperability Between Rust and C++ by avgcorrection on Monday February 05, 2024 @04:03PM (#39267145)
Is “erased” how Haskell typeclasses work?
Re:Improving Interoperability Between Rust and C++ by tome on Monday February 05, 2024 @04:09PM (#39267212)
No, the opposite. They're either specialized (when they can be) or (effectively) existential (when they must be). That is, the compiler either inlines the specific definition of the type class methods if it knows them, or passes them around at run time.
Re:Improving Interoperability Between Rust and C++ by Ericson2314 on Monday February 05, 2024 @05:09PM (#39267944)
Agreed, except I would not call it "existential"

C++ stores references to dictionaries from/with the things they describe, that's "existential"

Haskell passes in extra parmeters that are dictionaries and doesn't (except for user-written code that does) keep around extra references to them. That's more like "universal" than "existential".

Re:Improving Interoperability Between Rust and C++ by Ericson2314 on Monday February 05, 2024 @04:29PM (#39267485)
Erased is how types in Haskell work. Type classes are compiled as "dictionaries": structs of methods. Sometimes they can specialize them (just pull the thing out of the dictionary statically), but in general they become that extra parameters at run time.