Translate Haskell Class-based ad-hoc polymorphism example to Scala

It’s needed for “single abstract method” class instantiation via a lambda. Besides, when choosing between an abstract class and a trait, I always pick the abstract class. It’s more straightforward and thus faster to compile since it maps directly to a Java abstract class, whereas traits do not (though this usually only makes a difference in big mixin composition use cases).

1 Like