4 ms·
Is “erased” how Haskell typeclasses work?
by avgcorrection 3y ago
Is “erased” how Haskell typeclasses work?
- tome 3y agoNo, 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.
- Ericson2314 3y agoAgreed, 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".
- Ericson2314 3y agoErased 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.