The Art Of the Small: scalaz library

As you may have noticed, I have published a few blogs on using the scalaz library.  As I have worked through some examples, I had a growing feeling that scalaz was hard to use.

For someone new to scala, this is true (let's ignore the lack of documentation issue for now).

Why is this so? After thinking about, I realized that scalaz is designed to implement solutions to a variety of functional problems. These typically involve monoids and other structures. Monoids operate at a small scale. In other words, they are each designed to do a very small job.

Because each part of the library is designed to do a very small job, they are ideal for implementing software using small, concise layers. Since monoids encode the programmer's intent into the type system (e.g. State, Reader, Writer), scalaz has many types of class that all perform small, monoidal jobs.

The scalaz library is not designed to be a full dependency injection library, say like spring or guice. spring implements a fairly large concept of dependency injection as a fully implemented concept for integrating classes to create applications. That's a big job. As you might expect, the spring library, while you can use only a small part of it if you wish, is highly useful, but larger library.

scalaz excels at helping you perform small jobs so naturally there are many components to learn and you have to learn how to compose them together. That makes it look or at least feel, more complex. Just like poetry, where concision and context are key, the same is true for scalaz. It takes awhile to get used to reading poetry well, and in the same spirit, it takes awhile to getting to use scalaz well.

So for someone who is using functional programming techniques and knows scala, its not hard to use.

P.S. The library still needs more documentation and real-word examples.

Comments

Popular posts from this blog

quick note on scala.js, react hooks, monix, auth

zio environment and modules pattern: zio, scala.js, react, query management

user experience, scala.js, cats-effect, IO