by jmite · 9y ago · 0 comments
Trait objects are basically existential types, with a few more restrictions on them. But in essence polymorphism in Haskell and Rust are very similar.
The big thing Rust is missing is higher kinded polymorphism, ie the ability to abstract over type constructors. This makes it easy, for example, to abstract over a container type while putting different things in that container.
This has get approved in the Associated Type Constructors RFC, but it's still in the works for actually landing.
Whilst this is obviously useful, it makes it impossible to perform parametricity type-based reasonbig.
Also, I'm not sure why you would ever want a "partial instance," as it would mean that your program could be unsafe but still typecheck (I haven't checked out Rust's implementation or motivation). Just use more specific classes, and you can even use a "generic" "instances of the components imply an instance of the whole" class and instance.
You can either have overloading classes or you can have your classes declaration independent of the type declarations. You can not have both.