3 ms·
is bounded another word for ad-hoc? I always considered Rust's polymorphism implementation like Haskell's, and AFAIK they call it ad hoc polymorphism.
by leshow 9y ago
is bounded another word for ad-hoc? I always considered Rust's polymorphism implementation like Haskell's, and AFAIK they call it ad hoc polymorphism.
- steveklabnik 9y agoIIRC, "bound" has more to do with quantification than polymorphism more generally. There is "parametric" vs "ad-hoc". https://stackoverflow.com/questions/6730126/parametric-polymorphism-vs-ad-hoc-polymorphism https://stackoverflow.com/questions/6730126/parametric-polym... has a link to the text of TAPL explaining the difference here. Rust traits and Haskell typeclasses would be ad-hoc.
- leshow 9y agoThat's interesting, I always assumed parametric polymorphism was a requirement of ad hoc polymorphism. I suppose I'm using a more narrow definition. On the opposite end, Elm for instance, has parametric polymorphism: type Parametric a = Parametric a f : (a -> b) -> Parametric a -> Parametric b f fn (Parametric a) = Parametric <| fn a but no support for ad-hoc, like you said, in Haskell: data Parametric a = Parametric a f :: Ord a => Parametric a -> Parametric a -> Parametric a f (Parametric a) (Parametric b) = Parametric (min a b)