Where communities thrive

  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
Repo info
  • Sep 05 2019 14:43
    @typelevel-bot banned @jdegoes
  • Jan 31 2019 21:17
    codecov-io commented #484
  • Jan 31 2019 21:08
    scala-steward opened #484
  • Jan 31 2019 18:19
    andywhite37 commented #189
  • Jan 31 2019 02:41
    kamilongus starred typelevel/cats-effect
  • Jan 30 2019 00:01
    codecov-io commented #483
  • Jan 29 2019 23:51
    deniszjukow opened #483
  • Jan 29 2019 23:37
  • Jan 29 2019 23:22
  • Jan 29 2019 20:26
    Rui-L starred typelevel/cats-effect
  • Jan 29 2019 18:01
    jdegoes commented #480
  • Jan 29 2019 17:04
    thomaav starred typelevel/cats-effect
  • Jan 28 2019 17:43
    asachdeva starred typelevel/cats-effect
  • Jan 28 2019 07:12
    alexandru commented #480
  • Jan 28 2019 05:45
    codecov-io commented #482
  • Jan 28 2019 05:35
    daron666 opened #482
  • Jan 27 2019 13:56
    codecov-io commented #481
  • Jan 27 2019 13:46
    lrodero opened #481
  • Jan 27 2019 05:47
    codecov-io commented #460
  • Jan 27 2019 05:37
    codecov-io commented #460
Luis Miguel Mejía Suárez
for? Or just plain flatMap?
flatMap still propagates Either/Option etc though, so if I have something returning an IO[Either[A,B]], flatMap will pass Either[A,B] to the callback
so I've still got to do the standard unwrapping
let me show you the terrible code I've managed to cobble together
  def registerIntegration(req: Request[IO], auth: String) = {
    // First check that we have the correct payload
        case None => BadRequest("Malformed request body")
        case Some(payload) => {
          // Check that the user referenced exists
              case None => BadRequest("No user found")
              case Some(_) => {
                // Unwrap the lightning auth header
                authStringToLightningAuth(auth) match {
                  case Left(st) => BadRequest(st)
                  case Right((user, pass)) => {
                    // Make sure we have the correct authentication
                      .getAccount(user, pass)
                        case Left(error) =>
                            s"Lightning ad server failed: $error"
                        case Right(accountName) => {
                          // Mark that the user is lightning registered
                            .flatMap(registered =>
                              if (registered)
                                Ok("Registered for lightning integration")
                                  "Failed to register for lightning integration"
it seems to me that I should be able to avoid this amount of identation in idiomatic scala/cats
but, I've no idea how :/
Luis Miguel Mejía Suárez
@CameronDiver So two things that may help.
Use EitherT or OptionT
(make sure to just use one, like convert all Eithers into Option or vice versa)
And then remember that foo.flatMap(x => x.bar.flatMap(y => ???)) is the same as foo.flatMap(x => x.bar).flatMap(y => ???)
i.e. you can always unnest flatMap calls.
The for syntax may help with that.
The unnested flatMap calls is huge, I didn't notice that! I'll check out how to use EitherT/OptionT too. Really appreciate the help!
Naftoli Gugenheim
You cannot always unnest flatMaps easily. For instance if y => ??? depended on x then to unnest you'd have to return a tuple to pass x along with the result of x.bar
Hi folks! Would it be possible to convert A => F[B] to F[A => B]? I'm definitely missing something.
Naftoli Gugenheim
@tpetillot try discord
@nafg done, thanks!
Hi guys, I'm playing with Cats Fibers and having hard time to find some information regarding the integration of Fibers and JVM NIO; specifically do Fibers block when calling NIO operations or are they somehow integrated with such calls and automatically poll/select on file/socket descriptors?
Or is such construct orthogonal to Fibers and user needs to provide such functionality?
湿垃圾 == 菜狗
Hi guys, for the past two days, I've iterated my code by times. I find a simple way to do something like macwire in cats use IO or Resource. First it only works in Scala3. Finally I choose cats-effect-cps, It becomes more maintainable and intuitive. And than we can do the same thing in zio.RIO, zio.ZManaged, Future because the support of cats-effect-cps. I organized my code on macwire issue Further in Scala3.2 it can be
Mario Siegenthaler
Hey, I'm having some weird issues with my application just completely locking up after some time. It's all cats effect 3.3.13 (http4s server that makes calls to some old-school blocking apis [keycloak client wrapped with IO.interuptibleMany]). What I observed is that I seem to loose all cats-effect compute threads (io-compute). At the beginning I have two, then some compute-blocker in addition, then when it works I consistently see only the io-scheduler and no other io-* threads..
1 reply
Tomas Klubal
Hi all, why is the WorkStealingThreadPool#shutdown() calling Thread.currentThread.interrupt()? It causes the calling thread to die, which might not be desirable.
Abdulkhamid Muminov
Hi all. Is there any resource expect official documentation to learn the cats-effect library and cats data structures? Somehow the official docs are quite hard to grasp it for the functional newbee, or I'd call imperative rookie :D Thanks in advance!
Luis Miguel Mejía Suárez
@homycdev hey, you may get more help in Discord but check the resources and examples I have here: https://github.com/pslcorp/programs-as-values
What are the correct imports that I should use to be able to use the Id Monad?
I have cats-core version 2.8.0 as a dependency in my project, and have the import cats._
but my IDE still could not find the Id Monad

I'm trying to use parReduceMapA on a List[Set[MyType]] where MyType has a Semigroup instance defined for it, but I'm getting the error:
could not find implicit value for parameter T: cats.Reducible[List]

The code is using tagless final, so it looks kinda like this

object MyService {
  def impl[F[_]: Spawn: Parallel]: MyService[F] = new MyService[F] {
    private def otherFunc(param1: String, param2: Set[MyType]): List[Set[MyType]] = ???

    def myFunc(param1: String, param2: Set[MyType]): F[List[Set[MyType]]] =
      for {
        myVal <- otherFunc(param1, param2).parReduceMapA(Applicative[F].pure)
        ... etc
Okay, figured this out: List can be empty, so requires a Monoid, and parFoldMapA operates on the Monoid instance, which is why that works and parReduceMapA does not work because it requires a non-empty container since it operates on Semigroup