Skip to main content
Filter by
Sorted by
Tagged with
0 votes
1 answer
95 views

I try to run function written on Scala with Cats IO using. Simple Scala functions from https://aws.amazon.com/blogs/compute/writing-aws-lambda-functions-in-scala/ and https://rockthejvm.com/articles/...
Alexander Chernetcov's user avatar
1 vote
1 answer
109 views

I have been trying to traverse a data structure in Scala and do two things at the same time. I have been using Cats library for this. Here's a little example which does not compile. I do not ...
user27895414's user avatar
0 votes
1 answer
60 views

Am trying to write a sample HTTP Service using TypeLevel Scala which hits the National Weather Service API. Am having type mismatch errors from the http4sVersion dependency and EntityEncoder from cats....
PacificNW_Lover's user avatar
2 votes
1 answer
59 views

I have the following definition of effect types that I use in my service: type Traced[F[_], A] = ReaderT[F, TracingCtx, A] type TracedErrorHandling[F[_], E, A] = Traced[EitherT[F, ...
smur89's user avatar
  • 348
0 votes
1 answer
72 views

I want to combine two endofunctors in the context of Option. The combining I want is by composing two endofunctors into one via Category.compose. I found that MonoidK[Endo].algebra[*] instance for ...
Max Smirnov's user avatar
1 vote
0 answers
94 views

I have a grpc service which ofer an API looking like that def f(input: fs2.Stream[F, Input]) : fs2.Stream[F, Output] the Input is basically formed like sealed trait Input case Data(x : ByteBuffer) ...
crak's user avatar
  • 1,675
1 vote
1 answer
379 views

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 ...
breadman2000's user avatar
2 votes
0 answers
126 views

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: ...
pathikrit's user avatar
  • 33.7k
1 vote
1 answer
122 views

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 ...
andres's user avatar
  • 11
0 votes
1 answer
126 views

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 = (...
Ali Tc's user avatar
  • 7
1 vote
0 answers
57 views

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 ...
Ákos Vandra-Meyer's user avatar
0 votes
1 answer
156 views

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[...
RobertJo's user avatar
  • 125
1 vote
0 answers
72 views

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: ...
Ali Tc's user avatar
  • 7
1 vote
1 answer
80 views

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[...
satyagraha's user avatar
2 votes
1 answer
240 views

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 ...
Jonathan Card's user avatar
0 votes
2 answers
105 views

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 ...
thlim's user avatar
  • 2,982
0 votes
0 answers
142 views

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 ...
Vladimir Korenev's user avatar
0 votes
1 answer
113 views

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 ...
christopher oates's user avatar
1 vote
1 answer
155 views

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] = ...
Randhir Kumar's user avatar
0 votes
1 answer
92 views

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) *> ...
Max Smirnov's user avatar
1 vote
1 answer
56 views

Reading both the documentation for Scalaz and Cats, I notice that they frequently use => in their generic/polymorphic field. For example, from the scalaz page on applicatives, it has the following ...
Leif Andersen's user avatar
2 votes
0 answers
79 views

In my code I need to create a database and create some tables in it using cats.effect. The code as following, def createTable[F[_]: Async]: Resource[F, ResultSet] = { val createTableQuery = &...
Hima_93's user avatar
  • 51
2 votes
1 answer
192 views

Haskell has a function for getting the current continuation getCC = callCC (\c -> let x = c x in return x) How to write a similar function in Scala? E.g. function callCC presents in cats.ContT. ...
Sergey Sviridov's user avatar
3 votes
1 answer
106 views

Assuming getData() returns an IO[_] and has all its side effects suspended, I fail to see any difference between getData().map(d => println(d.toString)) and getData().flatMap(d => IO(println(d....
Jaime Silva's user avatar
1 vote
1 answer
112 views

I want that user can run a timer with callback and able to cancel it. Something like this: def main: F[Unit] = for cancel <- runTimer(callback, 5.seconds) shouldCancel <- askUser ...
Max Smirnov's user avatar
0 votes
0 answers
49 views

Scala with Cats arise two issues as follow: And give the answer: But it seems that it could, like: sealed trait A final case object B extends A final case object C extends A trait Printer[-T]: ...
Kicey's user avatar
  • 103
2 votes
0 answers
72 views

I'm working on the Chapter 11 Case Study: CRDTs from the excellent book "Scala with Cats". The code in the book is written using Scala 2, but I've modified it for Scala 3, specifically 3.3.1....
Abhijit Sarkar's user avatar
0 votes
1 answer
242 views

I'm trying to port Scala2 / shapeless code to Scala3, and one thing I miss is a way to convert a HList of Resource to a single, type-safe Resource. In Scala2, I am able to use cats.sequence.Traverser'...
mauhiz's user avatar
  • 501
0 votes
2 answers
126 views

I want to create a FunctionK instance with anonymous function. Here is the minimal example of that: import cats.~> given (Option ~> List) = { case Some(a) => a :: Nil case None => ...
Max Smirnov's user avatar
1 vote
1 answer
241 views

How can I implement a similar Haskell function in Scala 3 and Cats? ghci> (+) <$> (+1) <*> (+1) $ 10 22 There was a solution using mapN. It is mentioned here, Using functions as ...
thlim's user avatar
  • 2,982
0 votes
0 answers
109 views

i'm lookning for solution to eleminate race condition in my code. Basically i have a write and read functions. These functions are called in a stream, of values. Stream itself is going through ...
Дима Шестаев's user avatar
0 votes
1 answer
84 views

i have a small problem. for map <- kafkaEventHoldLine.get // Ref[F, List[String]] key = dr.derived + dr.metricId.toString _ <- if !map.contains(key) then ...
Дима Шестаев's user avatar
0 votes
2 answers
149 views

Why does it not catch and print the exception msg from calculateTwo? If we make calculateOne throw the exception, the exception is caught and the msg is printed. package com.oxo.test import ...
Yalav's user avatar
  • 31
0 votes
1 answer
78 views

In the below method, only the exception coming from burnService.execute is getting caught in the catch. Any exception coming from earnService.execute is not getting caught. If I move the earnService,...
Yalav's user avatar
  • 31
0 votes
2 answers
274 views

I'm interested in a version of parEvalMap with a bounded buffer so that it will keep progressing the underlying stream as long as its buffer is not full. What I mean is onsidering a stream of values [...
Ákos Vandra-Meyer's user avatar
0 votes
1 answer
80 views

I have a simple slick query which run on database: def method(): Future[Either[Error, MyCustomDTO]] = OptionT(database.run(query)) .map(MyCustomDTO(_)) .toRight(dataNotFound()) .value The ...
Developus's user avatar
  • 1,462
0 votes
1 answer
51 views

Let's say that I have the following case classes: case class Record(a: String, b: String) case class Result(c: Int, d: Int) And a function that does a bunch of things and then returns an IO[Result] ...
yet_another_programmer's user avatar
-1 votes
2 answers
108 views

I need to run IO action on interval if flag is set to true. Flag could be set to true multiple times during one interval from other places of program. For example: class IntervalAction { def touch: ...
Егор Лебедев's user avatar
0 votes
1 answer
184 views

I have this function that inserts a One To Many relationship representation between 3 tables: def insertRelations(cs: TableA): Fragment = { sql"""INSERT INTO my_schema.table_a ( ...
joesan's user avatar
  • 15.6k
0 votes
1 answer
195 views

I have an implementation that looks like this: final class MyServiceImpl[M[_]: Async](dbCfg: DBConfig)(implicit ec: Scheduler) extends MyService[M] { ...... ...... ...... ...... } Inside this ...
joesan's user avatar
  • 15.6k
0 votes
1 answer
306 views

I have this in-memory implementation of a simple Cache in Scala using cats effects. Here is my trait: trait Cache[F[_], K, V] { def get(key: K): F[Option[V]] def put(key: K, value: V): F[Cache[F, ...
joesan's user avatar
  • 15.6k
0 votes
1 answer
592 views

I created a tiny worker system to run parallel jobs with maximum multi-core processor utilization. It seems to work fine, but at some point, when working with a larger amount of jobs, an error appears ...
Csaba Kincses's user avatar
2 votes
1 answer
650 views

Is there a way to shutdown the cats effect runtime from within an application, similar to System.exit(0)? There is a shutdown method on IORuntime but it is not documented and it behaves weirdly when I ...
Georg Prohaska's user avatar
2 votes
2 answers
257 views

When chaining a for comprehension with EitherT, the compiler is having issues upcasting my errors to their common ancestor type. I have the following type definitions in my code: sealed trait Error ...
Bruno Lemus's user avatar
3 votes
1 answer
470 views

Using http4s-ember-server on one of my applications I notice from time to time these exceptions appearing in my server's logs. What is odd about them is that they don't follow my logger's appender or ...
Hunor Kovács's user avatar
0 votes
1 answer
161 views

My code (below) is failing to compile after a Doobie library upgrade. fragments.or(filterFragments: _*) "Cannot resolve overloaded method 'or'". Presumably the signature has changed but I ...
Tom Squires's user avatar
  • 9,316
0 votes
1 answer
135 views

I am relatively new to cats effect. We are currently using Cats effect 2.x. I would like to understand how can we apply timeout for Async Type class. def myMethod[F[_]: Async, A]: EitherT[F, Error, A] ...
Dinesh Chandra's user avatar
1 vote
1 answer
222 views

A cats-effect fiber, once started, a reference kept of it, some other code executed and then rejoined, won't raise the errors that happen inside. Do you know why .join doesn't throw an error and why ...
Hunor Kovács's user avatar
0 votes
1 answer
200 views

I have some code that attempts to execute a series of futures within a for comp and returns the value of the completion of the comp. I want to implement a retry function on the entirety of the for ...
Kyle's user avatar
  • 1,524
0 votes
1 answer
86 views

I need to filter a list of items with a function that performs external call and returns a boolean wrapped into something (let's say a Future). So basically: def filter[A](list: List[A])(f: A => ...
Leonid Bor's user avatar
  • 2,304

1
2 3 4 5
20