Haskell for Scala Developers: Part 4 — Objects and Modules
Here's a thesis worth defending: most of Scala's object-oriented machinery is answers to questions Haskell never asks. Inheritance, trait linearization, the five different places a definition can live, private and its dozen qualifiers: a lot of it exists to manage complexity that a language built on data and functions doesn't generate.
That's the spicy half. Here's the fair half. OOP was solving four real problems: polymorphic dispatch, code reuse, modularity, and controlled mutation with encapsulation. Every language needs answers to those. Haskell doesn't ignore them. It answers each with something smaller and more honest than a class hierarchy, and I think the smaller answer is usually the better one. Where Scala's version earns its keep, I'll say so; it does in two or three places.
I'll use one running example throughout: a notification service. It's the classic OOP teaching object, with a polymorphic send, a hierarchy of channels, mixins that add retry and rate-limiting, and a private counter tracking deliveries. If you've sat through an "intro to OOP" course, you've written this exact class. We'll watch it dissolve into a handful of data types and functions, and I'll argue that what's left is what you actually wanted.