|
|
|
|
|
by jmite
3140 days ago
|
|
Rust's traits are basically Haskell typeclasses, with a few extensions enabled, like multiple parameters. 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.