Typeclasses In Scala
Here's a common object-oriented problem in OO languages such as Java.
You're using two libraries. One of them provides a class, say
Foo, which performs
some useful tasks. The other library provides a useful
bar method that takes
as an argument instances of
Barable, an interface. You've got no control on
either of the two libraries, but you'd like to be able to pass an instance of
Foo to the
bar method. Let's image it would save you a lot of work to do
this. However you can't.
Foo doesn't implement
Barable and you can't modify
Foo to have it implement the aforementioned interface. The normal solution