Two reasons type classes are superior to OOP-style interfaces: 1. You can define instances for 3rd party data types 2. You can use the same data but different logic Type classes decouple capabilities from both types and data, giving you increased flexibility and power.
You can write typeclasses in Smalltalk, just like you do in Common Lisp, using "Interface-Passing Style", with an explicit interface object.
-
-
Haskell type classes and OOP polymorphic dispatches are two entirely different things.
-
The former being ahead-of-time code replication based on type. The later bring runtime dispatch based on instance.
- 2 more replies
New conversation -
-
-
Certainly. I was referring to Smalltalk 'constructors' not being the abomination found in other (pseudo) OOPLs.
-
More precisely, being plain old methods, first class an' all.
End of conversation
New conversation -
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.
Read my blog!