Is OOP still relevant in Scalaz or Cats

Hey. I would like to ask someone who knows Cats or Scalaz library if in using them we reject or marginalize the OOP side of Scala or we can mix with functional programming strong OOP concepts like classes, singleton objects, path-dependent types in a similar way as before.

Short answer: yes you can, and you not only can but want.

Longer answer:
First it depends on what is your definition of OOP? For me it is using modularity to hide implementation details and you always want to do that.
If for you that means using features like classes and subtyping, then absolutely. Take a look to the source code of cats the typeclasses hierarchy is defined using traits and subtyping, and the data types are implemented using classes.

However, if your definition of OOP is mutability, dependency injection, excessive use of design patterns, and other things you see in a traditional Spring codebase. Then, well you can, but if you start to look more into things like cats-effect & fs2 you will see a new way to structure programs called the “Programs as Values” paradigm (which still uses OOP features to achieve modularity and encapsulation).

6 Likes