Hacker News new | ask | show | jobs
by lptk 2060 days ago
(I'm not the person you were asking, but:)

The power of Haskell's type classes comes from two things:

* Implicit composition of instances: you can write `show [True, False]`, which will automatically/implicitly compose the `Show` instances of lists and booleans. With modules or interfaces, you'd have to build and use a "BoolListShow" manually.

* Higher-kinded types, to abstract over type constructors. This enables the use of abstractions like monads.

Rust only has the first of these two.

Scala uses OOP interfaces instead, but by augmenting them with both capabilities (implicit composition and higher-kinded types), it achieves the same expressiveness as Haskell.