Type Classes - Traits
← Back to Advanced Type Features
A mechanism for ad-hoc polymorphism that defines a set of operations a type must support. Unlike OOP interfaces, type classes/traits can be implemented for existing types after the fact (retroactive conformance), enabling extensible abstractions.
Key Properties
Related
- Haskell type classes, Rust traits, Swift protocols