This blogpost explains and argues the claim that Ad-hoc polymorphism (Type-classes in Haskell/Scala/Purescript, Traits in Rust, Interfaces in Go/Java) makes code less type-safe.In other words: ad-hoc polymorphism makes it so that sometimes, after a refactor, code that is wrong and would not type-check without it, now still type-checks.
Yeah this one’s a miss on my end. I saw “ad-hoc polymorphism is UNSAFE?” and well, it does a better job reinforcing that ad-hoc polymorphism is not unsafe.
Author should have wrote a piece “how even type-safe programs can fail” and used his example to show that. Because what this really shows is that type-safety doesn’t prevent programs with the correct types but bad semantics. But that’s not ad-hoc polymorphism; it can happen anywhere (sans ultra-specific types) including even the author’s workaround if he used Vec<Vec instead
Yeah this one’s a miss on my end. I saw “ad-hoc polymorphism is UNSAFE?” and well, it does a better job reinforcing that ad-hoc polymorphism is not unsafe.
Author should have wrote a piece “how even type-safe programs can fail” and used his example to show that. Because what this really shows is that type-safety doesn’t prevent programs with the correct types but bad semantics. But that’s not ad-hoc polymorphism; it can happen anywhere (sans ultra-specific types) including even the author’s workaround if he used
Vec<Vec
instead