Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding helper function to instanciate caches within Cats Resource #220

Closed
wants to merge 6 commits into from

Conversation

GrafBlutwurst
Copy link

I couldn't figure out where and what sort of meaningful tests to add. so I'd be happy for any pointers.

implicit val io: Mode[IO] = new Mode[IO] {
val M: Async[IO] = asyncForCatsEffectAsync[IO]
}
object lowPrioModes {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a bit confused. Why do you need to split this into 2 objects? This would be a breaking change for anyone who is using cats-effect Async but not IO.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh yeah you're right. I was intending to make this a proper lowPrio trait but screwed it up. I had ambigous implicit issues for Async[IO] due to both the explicit instance io and the def async matching. Why are those both in there and not just the async one since that should cover cats IO as well?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah well now I have an odd diverging implicit expansion for type cats.effect.Async[F] I'll takle this tomorrow.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Explanation of why both IO and Async are there: #173 (comment)

But the IO one could probably be removed without anyone noticing, if it's causing you problems.

@GrafBlutwurst
Copy link
Author

So even though all the tests are passing now I have a weird situation provoking "diverging implicits"

import scalacache._
import scalacache.caffeine._
import scalacache.CatsEffect.modes._
import cats.effect.IO

object Main {

  def main(args:Array[String]) = {
    val cacheResource = CatsEffect.resourceCache(IO {CaffeineCache[String]})

    implicitly[Mode[IO]] //works
    implicitly[Flags] //works

    val prog = cacheResource.use(
      cache => for {
        //diverging implicits
        _ <- cache.put("1")("a")//(CatsEffect.modes.async[IO], Flags())
        a <- cache.get("1")//(CatsEffect.modes.async[IO], Flags())

      } yield a
    )


    println(prog.unsafeRunSync)

  }

}

@GrafBlutwurst
Copy link
Author

I fiddled around with the implicit resolution error but without success. So any help is welcome. I'll try to find a second pair of eyes to have a look at this.

@lewisjkl
Copy link
Collaborator

Thinking that this will be done a different way now that #345 will remove modes and instead rely on cats-effect typeclasses. I am going to close this for now and we can look into more alternatives once #345 is merged in.

@lewisjkl lewisjkl closed this Feb 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants