5 ms·
> Rust has generics, which are higher order types (you can't have just a vector, it needs to be a vector "of something"). I'm not sure if the rust team would d
by dbaupp 12y ago
> Rust has generics, which are higher order types (you can't have just a vector, it needs to be a vector "of something"). I'm not sure if the rust team would describe them that way, but there doesn't seem to be that much of a theoretical difference.
No, there's no first class "type level functions", i.e. you always need `Vec<T>`, and you can't ever write `Vec` by itself, which is what a true higher-order type is (and what Functor needs:
impl Functor for Vec { ... }
impl Functor for Option { ... }
Thus, your example isn't at all possible now or even in the near future.
- thinkpad20 12y agoI'm aware that my example isn't possible, which is why I said, "if they wanted to, they (presumably) could allow for..." My point being that Rust restricts what one can do with higher-order types, but those types still exist and are expressible in the language. From a theoretical point of view, there doesn't seem to be any reason that they couldn't allow for traits on higher-kinded types -- they simply choose not to. Perhaps for performance reasons, or for simplicity, or for syntax or whatever, but I haven't seen any reason why they couldn't. That was the point that I was making.