by

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
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
what behaviour do you want it to have?
what I mean is that I'm unclear is what you've written is the behaviour you see or the behaviour you want
Ross A. Baker
@rossabaker
I want the f in the first argument to race to run before fa can complete, but I still want to race those two effects.
Fabio Labella
@SystemFw
Deferred[F, Unit].flatMap { gate =>
  F.race(F.async(cb =>  gate.complete(()) *> f(cb)), gate.get *> fa)
}
Ross A. Baker
@rossabaker
Concretely, I want to addListener on the servlet's AsyncContext before anything else can complete() it.
I thought about Deferred. I'd also like to cancel the right if the left wins.
Fabio Labella
@SystemFw
Not entirely bullet proof, if fa is super fast
Ross A. Baker
@rossabaker
Oh, that's a little different than what I was trying. Hmm.
Fabio Labella
@SystemFw
I think the canceling behaviour is embedded in race already
Ross A. Baker
@rossabaker
Yeah, I wasn't thinking of burying a race inside the Deferred.
Fabio Labella
@SystemFw
the deferred inside the race you mean
it can still fail
if fa completes after during the left hand side *>
but that's unavoidable unless you can be more granular in your f
Ross A. Baker
@rossabaker
Could run f(cb) before the gate.complete()
Fabio Labella
@SystemFw
i.e. complete the gate when the registration is done, but before the part you want to race
if you ran f(cb) before, you won't be racing anymore, no?
well, I guess it depends on the f
Ross A. Baker
@rossabaker
asyncF(cb => F.delay(f(cb)).guarantee(gate.complete))
Fabio Labella
@SystemFw
right, it depends on f
Ross A. Baker
@rossabaker
The real f is asyncContext.addListener(new AsyncTimeoutHandler(cb))
Fabio Labella
@SystemFw
if f calls cb and then goes on to do other things asyncly, then yes