vlovgr/ciris

Why Cats Effect?

etspaceman opened this issue · 4 comments

Hello!

I have been using Ciris for a little while now. I am preparing an upgrade to the 1.x version, and I noticed that the entire library now depends on Cats Effect. I guess I'm trying to find out why. The PR that introduced this had no description or issue.

Effects tend to be used to contain side effects, but aren't your functions for checking environment variables and whatnot pure? If so, wouldn't we want to use something like MonadError[ConfigError, A]? The extra effect layer is a bit of a burden to work with and I'm just curious as to why these decisions were made. I would think that I should be able to run a ConfigValue.load without introducing any side effects.

Other things that confuse me is that the api requires an Async and ContextShift instance as well for loading. Why would every load call require these instances? Shouldn't I be able to load configuration in a synchronous way if I don't want parallelism?

So I've been thinking about the answer to "why Cats Effect" and I think it now makes sense. The evaluation of system properties/files/environment variables can throw exceptions, and an effect makes sense for handling these.

I am still confused WRT my 2nd question - why do we need ContextShift and Async instances for loading routines?

I will close this issue and open a new one specific to that question.

Ah I see the answer to this question in the scala doc, you use this for error accumulation.