All Questions
Tagged with scala scala-cats
945
questions
1
vote
1
answer
53
views
Scala Fs2: Aggregate computation on infinite streams
I cant seem to understand how to perform aggregate computations on infinite streams. Taking an infinite stream of elements and performing a computation on each one individually is easy, but collecting ...
0
votes
0
answers
42
views
How to force pull in fs2.Stream
I created an fs2.Stream with:
topic <- Stream.eval(fs2.concurrent.Topic[F, Either[Throwable, AmqpMessage[Array[Byte]]]])
messages <- Stream.resource(topic.subscribeAwait(innerQueueSize))
...
2
votes
0
answers
95
views
Are BFS and DFS the same and just the Monad is different?
I wrote a tail-recursive BFS in Scala:
import scala.collection.mutable
/** Do BFS from start and return the smallest distance to end (None if not connected) */
def bfs[A](start: A, end: A, neighbors: ...
1
vote
1
answer
33
views
How can I update a variable within my Http4s service every set interval of time?
I am trying to continually refresh a value after a set interval of time within an Http4s service. Up until now it's been defined as just a val that maintains its initial value. I would like to ...
0
votes
1
answer
40
views
Set up and use the Cats library for typeclass derivation in my Scala 3.4.2 project
Good Day,
I am using Intellij 2024.1.3 and
Oracle OpenJDK 22.0.1
this is my build.sbt:
ThisBuild / version := "0.1.0-SNAPSHOT"
ThisBuild / scalaVersion := "3.4.2"
lazy val root = (...
1
vote
0
answers
42
views
How to combine multiple ordered streams efficiently?
Given a List[Stream[F[_], A], where A <: Ordered, and each stream contains an ordered list of elements, what is an effective way to combine these streams into a single, ordered stream of all ...
0
votes
1
answer
96
views
EitherT with Scala type alias
Try to use type alias with EitherT get compilation error
type FuEiErr[T] = Future[Either[Error, T]]
type FuEiErrInt = Future[Either[Error, Int]]
case class Error(msg: String)
def fA(x:Int): FuEiErr[...
1
vote
0
answers
36
views
I use Scala 3.3.3 and would like to test a small program using import cats.kernel.laws.IsEq - I get this error: laws is not a member of cats.kernel
I am using Scala 3.3.3 and would like to test a small program using import cats.kernel.laws.IsEq, I get this error message: "laws" is not a member of cats.kernel and here is my
build.sbt:
...
1
vote
1
answer
59
views
Incorrect Show auto derivation involving NonEmptyList
This program:
package domain
import cats.{Show, derived}
import cats.data.NonEmptyList
import cats.implicits._
case class Error(code: String, message: String)
case class Errors(errors: NonEmptyList[...
2
votes
1
answer
83
views
ScalaFX and Cats Effect
I am trying to integrate Cats Effect into a ScalaFX desktop application, and I am having trouble getting the tasks to execute. I would like to run a background thread/fiber to initialize the window ...
0
votes
2
answers
58
views
Where Is The Implementation for Traverse[IO]
val foo: IO[List[Int]] = List(IO.pure(100)).sequence
Where do I find the implementation for the sequence method? I presume there is a Traverse typeclass implementation for cats.effect.IO and where ...
0
votes
0
answers
76
views
Changing error type of ApplicativeError/MonadError
I use a library that produces a result with some custom error type. This library defines MonadError for that result type. For compatibility with the rest of my application, I'm trying to get ...
0
votes
1
answer
51
views
Why does Maven download hundreds of versions of maven-metadata.xml for dependency when I explicitly stated a non-snapshot version in pom.xml?
At my company we're upgrading to a new version of Scala but when I run mvn clean install, near the end of the build, it spends 22 minutes (!) trying to download metadata about these 3rd party ...
1
vote
1
answer
55
views
Handling Exceptions in Scala FS2 Stream Transformation flow
import cats.effect.{IO, IOApp}
import fs2.Pipe
import fs2.Stream
object Test extends IOApp.Simple {
final case class Student(id: Int, name: String)
private val studentData: Map[Int, Student] = ...
0
votes
1
answer
51
views
How to call Cats typeclass method without specifying it explicitly?
I want to write that code:
IO.foreverM:
IO.sleep(1.seconds) *> IO.println("Tick")
But it doesn't compile. However this code compiles:
FlatMap[IO].foreverM:
IO.sleep(1.seconds) *> ...