On Tue, Mar 25, 2014 at 6:00 PM, Patrick Walton <pcwal...@mozilla.com>wrote:
> On 3/24/14 11:46 PM, Nick Cameron wrote: > >> Currently we forbid bounds on type parameters in structs, enums, and >> types. So the following is illegal: >> >> struct S<X: B> { >> f: ~T<X>, >> } >> > > IIRC Haskell allows bounds on type parameters (and we did once too), but I > heard that considered deprecated and not preferred. I don't recall the > exact reasons, but that's why we removed the feature (and also just for > language simplicity). > > Patrick > > If I remember the reason cited in Haskell design it was that some functions require more bounds than others. For example a HashMap generally requires that the key be hashable somehow, but the "isEmpty" or "size" functions on a HashMap have no such requirement. Therefore, you would end up with a "minimal" bounds precised at Type level, and then each function could add some more bounds depending on their needs: that's 2 places to specify bounds. In the name of simplicity (and maximum reusability of types) Haskell therefore advise to only use bounds on functions. However, I seem to remember than in Haskell the bounds are only Traits; whereas in Rust some bounds may actually be required to be able to instantiate the type (Sized ?). -- Matthieu > _______________________________________________ > Rust-dev mailing list > Rust-dev@mozilla.org > https://mail.mozilla.org/listinfo/rust-dev >
_______________________________________________ Rust-dev mailing list Rust-dev@mozilla.org https://mail.mozilla.org/listinfo/rust-dev