3 ms·
OOP classes (well, their instances) combine data and functionality into a single "thing" (well, object). Inheritance is nasty because you are not just composing
by elnygren 9y ago
OOP classes (well, their instances) combine data and functionality into a single "thing" (well, object). Inheritance is nasty because you are not just composing structures of data or interfaces of functionality but both at the same time.
When you separate data from functionality into separate "things", composing things out of them becomes nicer.
I'm not a Haskell programmer, but AFAIK type classes contain functionality, NOT data (state).
Example of what I'm talking about: Clojure's Protocols.