Questions tagged [cats-effect]

Part of the Scala Cats ecosystem for an IO type and associated effects.

191 questions
0
votes
1 answer

How to mock MVar2 make method

I'm having trouble mocking the MVar2 method make in my Unit test (using mockito). I tried this: private val sq = mock[MVar2[IO, String]] and when I tried to mock the method like: when(sq.take).thenReturn( "testString".pure[IO], …
amer
  • 1,528
  • 1
  • 14
  • 22
0
votes
1 answer

Convert implicit def to scala 3 given syntax

For the following Random UUID generator using cats effect: import java.util.UUID import cats.effect.Sync import cats.ApplicativeThrow trait UuidGen[F[_]]: def make: F[UUID] def read(string: String): F[UUID] object UuidGen: def apply[F[_]:…
TheKojuEffect
  • 20,103
  • 19
  • 89
  • 125
0
votes
1 answer

fs2.Stream hangs on taking twice

Problem: I want to repeatedly take some batches from the fs2.Stream provided by some third-party library and therefore abstract clients away from the fs2.Stream itself and give them simply F[List[Int]] batches as soon as they are ready. Attempts: I…
Some Name
  • 8,555
  • 5
  • 27
  • 77
0
votes
1 answer

Does TVar in cats-stm require an immutable value?

Ref in Cats-effect or Zio requires to work with immutable value over the mutable references, because of the underlying java compareAndSet from AtomicReference, I wonder if it is the case with TVar with cats-stm ?
MaatDeamon
  • 9,532
  • 9
  • 60
  • 127
0
votes
0 answers

local effects and mutable state in Scala with Cats

In Functional Programming with Scala Chapter 14 (local effects and mutable state), the author state the following: We’ll call this new local-effects monad ST, which could stand for state thread, state transition, state token, or state tag.…
MaatDeamon
  • 9,532
  • 9
  • 60
  • 127
0
votes
1 answer

fs2 evalFold? Fold by evaluating effects?

I would like to be able to evaluate every step while folding an fs2 stream. Stream.iterable[F, Int](List(1, 2, 3, 4, 5)) .evalFold(0){ case (acc, e) => logger.info(acc + e).as(acc + e) } Do you know a way to do this? Can you write up a helper…
Hunor Kovács
  • 1,062
  • 9
  • 16
0
votes
1 answer

request timeout from flatMapping over cats.effect.IO

I am attempting to transform some data that is encapsulated in cats.effect.IO with a Map that also is in an IO monad. I'm using http4s with blaze server and when I use the following code the request times out: def getScoresByUserId(userId: Int):…
gutscdav000
  • 359
  • 1
  • 3
  • 14
0
votes
1 answer

Filtering a collection of IO's: List[IO[Page]] scala

I am refactoring a scala http4s application to remove some pesky side effects causing my app to block. I'm replacing .unsafeRunSync with cats.effect.IO. The problem is as follows: I have 2 lists: alreadyAccessible: IO[List[Page]] and pages:…
gutscdav000
  • 359
  • 1
  • 3
  • 14
0
votes
1 answer

Mockito error when trying to mock cats.effect.IO

I'm trying to mock cats.effect.IO by val ioSql: IO[Sql[IO, SqlConnection[IO]]] = mock[IO[Sql[IO, SqlConnection[IO]]]] Sql and SqlConnection are my company libraries. I've got this error Underlying exception :…
TheOutsider
  • 63
  • 1
  • 10
0
votes
1 answer

Big Query Job state done before the query finishes

I have a scala application that creates a tsv table using BigQuery. When a user tries to access the data I want to return it if the query job is finished, otherwise tell them it's still running. My query job creation looks like this: …
0
votes
0 answers

When it's necessary to have more than 1 instance of Blocker?

In the documentation of Blocker there's the following paragraph: Instances of this class should NOT be passed implicitly because they hold state and in some cases, your application may need different instances of Blocker. Why in some cases I would…
Krzysztof Atłasik
  • 21,985
  • 6
  • 54
  • 76
0
votes
1 answer

Scala singleton objects and implicit resolution

What is the best way to make implicit resolution in scala work with singleton objects? This is especially common with Either and custom error objects. In the code example below a method returns an application-specific error wrapped in IO. The error…
Lev Denisov
  • 2,011
  • 16
  • 26
0
votes
0 answers

Is it possible to stop all streams when algebra provides?

I have the following trait that returns fs2.Stream trait Test { def action(arg: Int): fs2.Stream[IO, Unit] } The returned fs2.Streams are infinite and therefore one should be able to stop them. Given an implementation of trait Test is it…
St.Antario
  • 26,175
  • 41
  • 130
  • 318
0
votes
0 answers

Why can't SemigroupK.combineK syntax be used for Resource[F, ?]?

Consider the following simple application: import cats.effect.Resource import cats.{Monad, SemigroupK} import cats.syntax.semigroupk._ object ResourceSemigroupK extends App { //Error: value combineK is not a member of class Resource def…
Some Name
  • 8,555
  • 5
  • 27
  • 77
0
votes
1 answer

Missing Implicit for Log Cats.Effect.IO

I am trying to get this simple example running using the redis4cats library: import cats.effect._ import cats.implicits._ import dev.profunktor.redis4cats.Redis import dev.profunktor.redis4cats.effect.Log.noop object QuickStart extends IOApp { …
Mojo
  • 1,152
  • 1
  • 8
  • 16
1 2 3
12
13