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 14:43
    @typelevel-bot banned @jdegoes
  • Jan 31 21:17
    codecov-io commented #484
  • Jan 31 21:08
    scala-steward opened #484
  • Jan 31 18:19
    andywhite37 commented #189
  • Jan 31 02:41
    kamilongus starred typelevel/cats-effect
  • Jan 30 00:01
    codecov-io commented #483
  • Jan 29 23:51
    deniszjukow opened #483
  • Jan 29 23:37
  • Jan 29 23:22
  • Jan 29 20:26
    Rui-L starred typelevel/cats-effect
  • Jan 29 18:01
    jdegoes commented #480
  • Jan 29 17:04
    thomaav starred typelevel/cats-effect
  • Jan 28 17:43
    asachdeva starred typelevel/cats-effect
  • Jan 28 07:12
    alexandru commented #480
  • Jan 28 05:45
    codecov-io commented #482
  • Jan 28 05:35
    daron666 opened #482
  • Jan 27 13:56
    codecov-io commented #481
  • Jan 27 13:46
    lrodero opened #481
  • Jan 27 05:47
    codecov-io commented #460
  • Jan 27 05:37
    codecov-io commented #460
λoλcat
@catostrophe
bracket implementations for all transformers just ignore additional effects
λoλcat
@catostrophe
There's no laws for release. Do we need some?
Fabio Labella
@SystemFw
@catostrophe I would open an issue with that snippet. Better to have everyone see it
λoλcat
@catostrophe
Ok. Will do
λoλcat
@catostrophe
Viktor Lövgren
@vlovgr
@catostrophe the same behaviour should happen when using asyncF, unless I'm mistaken. Have you tried it?
Luka Jacobowitz
@LukaJCB
@catostrophe I think it’s actually impossible to write a bracket implementation that does what you expect with its current signature
λoλcat
@catostrophe
@vlovgr you're right. The same behavior.
λoλcat
@catostrophe
Thanks, reading...
Viktor Lövgren
@vlovgr
@catostrophe thanks for verifying. I only noticed this because I wrote a IOLog newtype over IO and noticed I had to discard the logs in only two cases: release for bracketCase and in asyncF. (Blog post likely out tomorrow, looks related to what you're doing.)
λoλcat
@catostrophe
@LukaJCB I've read that old thread, "impossible to write ... with current signature" doesn't look as an appropriate excuse ;) @oleg-py raised a concern I agree with (https://github.com/typelevel/cats-effect/pull/113#issuecomment-363461345) and you seemed to agree but then you crossed it out (https://github.com/typelevel/cats-effect/pull/113#issuecomment-374628912) and @alexandru said it's fine. But I still don't get why it's ok to ignore last change in WriterT or StateT.
Jakub Kozłowski
@kubukoz
so whatever happens in release doesn't get propagated to the whole bracket call's result?
λoλcat
@catostrophe
@kubukoz Aux effects of transformers don't. But the main effect of F does.
Jakub Kozłowski
@kubukoz
right
upd
@prayagupd
While learning cats-effect IO- https://typelevel.org/cats-effect/datatypes/io.html#parmapn, I found an parMapN example missing ContextShift[IO]. I thought it could be helpful to add one way to provide contextShift helpful noobs like me. So created a pull request https://github.com/typelevel/cats-effect/pull/372/files
upd
@prayagupd

Learning Question: I'm trying to run the cats.effect.Resource example from https://typelevel.org/cats-effect/datatypes/resource.html#example. I get value map is not a member of cats.effect.Resource[cats.effect.IO,String]. Wondering why is it looking for map not flatMap,

 // example taken from https://typelevel.org/cats-effect/datatypes/resource.html#example
  test("cats Resource") {

    import cats.effect.{IO, Resource}
    import cats.implicits._

    def mkResource(data: String): Resource[IO, String] = {
      val acquire = IO(println(s"Acquiring $data")) *> IO.pure(data)

      def release(res: String) = IO(println(s"Releasing $res"))

      Resource.make(acquire)(release)
    }

    val out: Resource[IO, String] = mkResource("outer")
    val in: Resource[IO, String] = mkResource("inner")

//    val rr = out.flatMap { a =>
//      in.flatMap { b =>
//        Resource.pure((a, b))
//      }
//    }

    //    out.map { o =>
    //      in.map { i =>
    //        (o, i)
    //      }
    //    }

    val r = for {
      outer <- out
      inner <- in
    } yield (outer, inner)

    r.use { case (x, y) => IO(println(s"Using $x and $y")) }.unsafeRunSync

  }

Error

Fabio Labella
@SystemFw
that code compiles for me
you probably don't have partial unification on
scalacOptions += "-Ypartial-unification"
upd
@prayagupd
Ohh, i did not have -Ypartial-unification whatever that does. But once I expanded for comprehension to flatMap I got it working.
Fabio Labella
@SystemFw
you should have that option always on
upd
@prayagupd
hmm, it was type inference issue? Probably I had same issue yesterday *> not being recognised unless i specified type in missileFiber.cancel *> IO.raiseError(error)
Gavin Bisesi
@Daenyth
that option is related to type inference, yes
Fabio Labella
@SystemFw
@prayagupd yes, that's the same problem
that option fixes a bug in the type system that occurs when you want to make a type of more than one type parameter fit into a one type parameter shape
for example
Resource[IO, String] (G[_, _]) needs to fit into F[_] so that you can fetch Monad[F] to get flatMap
which it can by having F[_] be Resource[IO, ?]
so by partially applying Resource so it can unify with F[_]
that's what partial unification does
it will be on by default in scala 2.13, for now you need to have it always on
other examples would be traverse on Validated or Either (you need F[_] for Applicative, but they have two type parameters) and so on
or indeed *> on Fiber[F, A] (I hope you can see the pattern)
doing *> on IO or Option won't expose the bug, since those types already have an F[_] shape
upd
@prayagupd
thank you very much for explanation @SystemFw. that is very helpful. I now remember giving up many times earlier while learning the example, as i did not have the flag on.
Abdhesh Kumar
@abdheshkumar
Thank you @SystemFw for nice explaination with an example, now I understand use of -Ypartial-unification.
Fabio Labella
@SystemFw
ah, cool :)
Ross A. Baker
@rossabaker
I've got a tricky one: F.race(F.async(cb => f(cb)), fa), where if fa completes before f runs, it's an error.
upd
@prayagupd
Okay, cats wiki mentions about partial-unification at least https://typelevel.org/cats, might be useful to mention in cats-effect as well
Fabio Labella
@SystemFw
you can learn more about that option here https://gist.github.com/djspiewak/7a81a395c461fd3a09a6941d4cd040f2
Abdhesh Kumar
@abdheshkumar
Ok thank you @SystemFw
Fabio Labella
@SystemFw

I've got a tricky one: F.race(F.async(cb => f(cb)), fa), where if fa completes before f runs, it's an error.

@rossabaker wdym?

Ross A. Baker
@rossabaker
It's that http4s error with Jetty and Monix, though I'm pretty sure Monix has nothing to do with it.
We register an async timeout handler to complete a callback to race against the response.
Fabio Labella
@SystemFw
why does it behave differently than what you expected?
ah, I guess it shouldn't fail
Ross A. Baker
@rossabaker
It behaves exactly like I expect, and I can't make it behave like I need to.
Fabio Labella
@SystemFw
but succeed with fa
I'm confused then