cats-effect Questions
1
During a PR review, I was asked to replace Sync[F].delay with Sync[F].catchNonFatal because an exception might be thrown.
This does work:
scala> Sync[IO].delay(throw new Exception).recover{ ca...
Soapsuds asked 13/2, 2019 at 18:50
4
Solved
Say I have a set of rules that have a validation function that returns IO[Boolean] at runtime.
case class Rule1() {
def validate(): IO[Boolean] = IO.pure(false)
}
case class Rule2() {
def validat...
Tort asked 4/12, 2022 at 14:47
4
Solved
I'm trying to send an email in the same transaction as inserting user into a database with Doobie.
I know that I can lift IO into ConnectionIO by using Async[ConnectionIO].liftIO(catsIO) where cats...
Age asked 9/1, 2020 at 4:22
1
I'm learning the concept of F[_] as a constructor for other types, but how do you pronounce this to another human or say it in your head (for us internal monologue thinkers).
Similar to how x =>...
Monastic asked 24/12, 2021 at 1:42
3
Solved
I'm just starting my adventure with fs2 streams. What I want to achieve, is to read a file (a large one, this is why I use fs2), transform it and write the result to two different files (based on s...
Gytle asked 3/10, 2020 at 19:10
2
Solved
I am trying to migrate project from cats-effect 2 to cats-effect 3, i am using doobie for interacting with database. Previously i could lift ConnectionIO to IO as it was described, but with the upg...
Sheilasheilah asked 21/2, 2022 at 19:54
2
Solved
I am trying to convert Mules to Cats Effect 3 (CE3). Since it is a caching library, in its tests it needs (virtual) time to pass to test whether items will be expired. It is currently making fairly...
Batten asked 18/5, 2021 at 17:52
0
I have been browsing a lot around the subject.
Just from stackoverflow, the best comprehensive post i found were
Try[Result], IO[Result], Either[Error,Result], which should I use in the end
How to ...
Nicias asked 16/3, 2021 at 20:49
1
Solved
I am using Doobie and in the examples that I found, it uses unsafeRunSync, like:
sql"select name from country"
.query[String] // Query0[String]
.to[List] // ConnectionIO[List[String]]
...
Niall asked 28/1, 2021 at 20:33
1
Solved
I've got something like this (it's an example from https://github.com/typelevel/fs2, with my additions, which I marked with comments):
import cats.effect.{Blocker, ExitCode, IO, IOApp, Resource}
im...
Systematic asked 14/10, 2020 at 18:12
1
Solved
Using tagless final (without using IO, but rather a generic F) how can I abstract over something like this:
def doSomething(s: String): IO[Unit] = ???
List("authMethods", "secretEngines", "plugin...
Thunderclap asked 29/5, 2020 at 0:12
1
There is ApplicativeError[F,E] + F[A] and there is Either[E, A]. Both convey the message that the function could fail with an E or succeed with an A but I'm not sure about the different message the...
Radicel asked 28/4, 2020 at 14:57
2
When using a functional environment like Scala and cats-effect, should the construction of stateful objects be modeled with an effect type?
// not a value/case class
class Service(s: name)
def wi...
Wordless asked 4/10, 2019 at 21:26
1
Solved
I often do things like:
import cats.effect.Sync
import cats.implicits._
case class User(name: String)
case object Error extends Exception
def validate[F[_]: Sync](name: String): F[Either[Error, ...
Strive asked 9/11, 2019 at 9:37
1
According to the cats official document: https://typelevel.org/cats-effect/typeclasses/liftio.html, if we want lift something from IO to other container, you should implement LiftIO trait, but the ...
Illconditioned asked 12/9, 2019 at 0:47
2
Solved
I have a map of string to IO like this Map[String, IO[String]], I want to transform it into IO[Map[String, String]]. How to do it?
Straley asked 27/12, 2018 at 13:36
1
Solved
Just for the sake of quick clarity for someone who wants to start working with Scala FP library, on a journey to become better at pure FP.
Would someone clarify the difference/relation between Ca...
Factorage asked 3/7, 2019 at 10:57
1
Solved
I'm looking at cats.effect.concurrent.Deferred and noticed that all pure factory methods inside its companion object return the F[Deferred[F, A]], not just Deferred[F, A] like
def apply[F[_], A](i...
Bujumbura asked 25/2, 2019 at 12:23
1
Solved
This perhaps been asked many times before, but none of the suggestions I've found help.
I have a simple Scala code that generates long number that depends on some side-effects. I'm wrapping thing ...
Pooka asked 18/2, 2019 at 4:27
1
Solved
I am trying to get some basic file IO (write/read) in a purely functional way using cats-effect. After following this tutorial, here is what I ended up with for reading a file:
private def readFil...
Fullgrown asked 6/2, 2019 at 7:55
1
Solved
import cats._
import cats.implicits._
trait Console[F[_]]{
def readInput() : F[Int]
def print(msg: String) : F[Unit]
}
class Foo {
def doFoo[F[_]: Monad](number: Int)(implicit C: Console[F]) ...
Preoccupied asked 4/2, 2019 at 5:8
1
Solved
In general I have problems figuring out how to write tailrecursive functions when working 'inside' monads. Here is a quick example:
This is from a small example application that I am writing to be...
Snowfall asked 2/2, 2019 at 10:28
1
I want to combine multiple IO values that should run independently in parallel.
val io1: IO[Int] = ???
val io2: IO[Int] = ???
As I see it, I have to options:
Use cats-effect's fibers with a fo...
Suzisuzie asked 13/1, 2019 at 13:35
1
Solved
I have a http4s project which uses ciris for configuration management.
The project is in github here.
libraryDependencies ++= Seq(
"is.cir" %% "ciris-cats",
"is.cir" %% "ciris-cats-effect",
"i...
Deragon asked 7/1, 2019 at 1:57
1
Solved
For few days I have been wrapping my head around cats-effect and IO. And I feel I have some misconceptions about this effect or simply I missed its point.
First of all - if IO can replace Scala's...
Perversion asked 8/12, 2018 at 12:49
1 Next >
© 2022 - 2024 — McMap. All rights reserved.