Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 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
josiah_sama
@josiah_sama:matrix.org
[m]
so until i figure out my own deployment of the Matrix home server, I'm stuck running like, 4 chat apps
Well, Let's start with FiberIO, because that's really the type most things are returning
how could I take Fiber[IO, Throwable, A] and redefine IO to just be Spawn?
Luis Miguel Mejía Suárez
@BalmungSan
As a return type?
josiah_sama
@josiah_sama:matrix.org
[m]
well, take a look at the docs, for example
give me a second to dig that up
I really want to define a bunch of functions that look like def myf(input: String): F[Fiber[F, Throwable, A]] = ??? where F forms a Spawn
Luis Miguel Mejía Suárez
@BalmungSan
Yeah I know what FiberIO is, you say you have a couple of methods that return FiberIO you want to replace that with Fiber[F] but be sure Spawn[F] exists
Right?
That type is not possible to be expressed. And you should not need to
josiah_sama
@josiah_sama:matrix.org
[m]
yes
why should I not need to?
I don't understand that
Luis Miguel Mejía Suárez
@BalmungSan
Just return the generic F
Users of that would just ask for the evidence of Spawn[F]
josiah_sama
@josiah_sama:matrix.org
[m]
so the Function itself just returns a normal fiber wrapped by F, and then the code consuming the output of those functions would look for an implicit definition of Spawn for F?
Luis Miguel Mejía Suárez
@BalmungSan
If that functions needs that yes.
josiah_sama
@josiah_sama:matrix.org
[m]
I suppose that makes sense
Luis Miguel Mejía Suárez
@BalmungSan
:)
As I said, without proper capability traits you will see your code just become more complex and less clear.
But I guess that is one of those things you need to live to see it.
If you can buy it, I recommend the Practical FP in Scala book by Gabriel Volpe
josiah_sama
@josiah_sama:matrix.org
[m]
is there a quick example I colud look at somewhere of a capability trait?
Luis Miguel Mejía Suárez
@BalmungSan
Sure look at Files in fs2.
Martin Carolan
@mcarolan
hi :wave: very confused person here. I'm expecting this test to pass, but it fails with s (i.e. the fold is calling the completed function instead of the errored). mind is a bit blown a bit, any ideas? https://github.com/mcarolan/ce3-noodling/blob/main/src/test/scala/example/HelloSpec.scala#L45
my conclusion atm is the fold on Outcome is not working as expected, but looking at the implementation that doesn't make sense
Adam Rosien
@arosien
@mcarolan i'm not sure how it compiles. fail("s") has type IO[A] => B?
Martin Carolan
@mcarolan

hmm that's fail from scalatest Assertions:

  def fail(message: String)(implicit pos: source.Position): Nothing = ...

so does fit in fold which is:

def fold[B](canceled: => B, errored: E => B, completed: F[A] => B): B = ...
compiles for sure, mind is boggled why the test fails
almost certainly a problem between the keyboard and monitor though, especially given Friday
oh, between keyboard and monitor confirmed

you're right, changing that line to

          o.fold(fail("c"), _ => succeed, _ => fail("s"))

also compiles, but the test succeeds as expected

crazy that it compiled without the _ => but failed the test
Martin Carolan
@mcarolan
maybe some implicit conversion somewhere that's making things fit but causing the fail to be evaluated ¯_(ツ)_/¯
cheers
Adam Rosien
@arosien
yeah. mixing basic scalatest (imperative) with effects is confusing/dangerous
Martin Carolan
@mcarolan
Ahhh gotcha
Adam Rosien
@arosien
oh, right, (F[A] => B) is a subtype of Nothing, so it compiles, but fail evaluates early
Martin Carolan
@mcarolan
Ah, yep that explains
Adam Rosien
@arosien
that fold signature encourages weird things, because the B should perhaps really be F[B], since you shouldn't really do a F[A] => B because that requires some unsafe method
Simon Leischnig
@simlei

hi guys, I have a problem with cats-effect tracing. I have actually never successfully used it. Maybe you can help:

libraryDependencies += "org.typelevel" %% "cats-core" % "2.3.0" withSources()
libraryDependencies += "org.typelevel" %% "cats-effect" % "3.1.1" withSources()
javaOptions += "-Dcats.effect.tracing.mode=full"
javaOptions += "-Dcats.effect.tracing.buffer.size=128"
javaOptions += "-Dcats.effect.tracing.exceptions.enhanced=true"
fork := true // if that's important I don't know

I used the example provided at https://typelevel.org/cats-effect/docs/tracing, and added the following snippet into the for-comprehension to check that the system property is actually set:

      _ <- IO { 
        import scala.collection.JavaConverters._
        val properties = System.getProperties().asScala
        for ((k,v) <- properties) println(s"key: $k, value: $v")
      }

i.e., this prints:

|| [info] key: cats.effect.tracing.mode, value: full // and the other keys, too

still, I'm getting just the regular stacktrace, nothing augmented. Completely at loss what else I could do.

Luis Miguel Mejía Suárez
@BalmungSan
@simlei you may want to ask in the Discord server which is more active: https://discord.gg/nUywkQsQ
Simon Leischnig
@simlei
Thanks!
Marco Lopes
@mlopes
Hi, I have some code that depends both on Sync and GenConcurrent, but then I get duplicate Functor/Monad/MonadCancel etc instances, so the compiler can't resolve which implicit syntaxe to use in, for example somethingThatReturnsAnF.map won't be able to find map. Is there a way to avoid this?
Luis Miguel Mejía Suárez
@BalmungSan
@mlopes well that is basically Async
Marco Lopes
@mlopes
Ah ok, sorry, I'm migrating something from ce 2 to 3 and wasn't familiar with GenConcurrent. Thanks 🙂
David Gutsch
@gutscdav000
Hello All, I've been trying to get Meow-mtl working with cats-effect 3. I see that that could be a problem as I'm not sure the repo has been upgraded. Does anyone know of a workaround? I'm just trying to do some simple error handling kind of like this:
case class MyException(msg: String) extends Throwable

def handleOnlyMy[F[_], A](f: F[A], fallback: F[A])(implicit F: MonadError[F, MyException]) =
  f.handleErrorWith(_ => fallback)

val io: IO[Int] = ???
handleOnlyMy(io, 42)
Adam Rosien
@arosien
@gutscdav000 you may need MonadError[F, Throwable] instead
David Gutsch
@gutscdav000

Turned out to be some library versioning issues. This is the upgrade permutation that worked for me:

"org.typelevel" % "cats-mtl_2.13" % "1.0.0",
 "com.olegpy" % "meow-mtl-core_2.13" % "0.5.0",
//      "com.olegpy" % "meow-mtl-effects_2.13" % "0.5.0" // <-- error

note meow-mtl-effects was incompatible, but not required for my specific use of the library for error handling.
Thanks for the response @arosien !