Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
Alexandru Nedelcu
@alexandru
It's not a sufficient example, because poll is not useful for those.
Fabio Labella
@SystemFw
I think it is though
Alexandru Nedelcu
@alexandru
Or I think it is, was going to write it :)
Fabio Labella
@SystemFw
the versions in cats-effect proper are a bit opaque because everything is written in terms of bracketFull
but basically you can start with uncancelable and onCancel, and derive higher level combinators from there
uncancelable { poll =>
   poll(fa).onCancel(fin.attempt.void).redeemWith(fin, fin)
}
something like that
for guarantee
Alexandru Nedelcu
@alexandru
nice
Fabio Labella
@SystemFw
still has enough subtlety to be interesting: the redeemWith needs to be the last thing, you need to explain onCancel and how its finaliser is always uncancelable, etc
Oleg Pyzhcov
@oleg-py
why does it need to be the last thing?
Fabio Labella
@SystemFw
the finaliser needs to be uncancelable
Oleg Pyzhcov
@oleg-py
poll(fa).redeemWith(...).onCancel would work too, no?
Fabio Labella
@SystemFw
if you put redeemWith before, the finaliser could be canceled on the success or failure case
Oleg Pyzhcov
@oleg-py
not if it's not in poll tho?
Fabio Labella
@SystemFw
actually no
you're right
even better
simpler to understand the point of poll actually
although it's generally good practice to do poll(fa).onCancel
for clarity
Oleg Pyzhcov
@oleg-py
yep was just about to say that
Fabio Labella
@SystemFw
you could explain with:
  • start without uncancelable, explain that cancelation can happen before redeemWith, and no finaliser will be run then
  • introduce uncancelable(_ =>, explain how nothing is cancelable now
  • explain a case where this is a problem, e.g. you want to timeout the task
  • introduce poll to selectively activate cancelation
  • explain how after poll, the redeem short-circuits
  • add onCancel, explain it
  • explain how the finaliser in onCancel is always uncancelable no matter what you do,including poll
something like that
Alex Nedelcu
@alexelcu:matrix.org
[m]
@SystemFw thanks for the advice earlier, I'm thinking of doing some sort of tutorial
Fabio Labella
@SystemFw
:+1: let me know how it goes, definitely a tricky subject
although I feel like with this model there is hope that a non maintainer can write interruption safe code. In CE2 there's no hope :smile:
Alexandru Nedelcu
@alexandru
@Avasil you online?
Piotr Gawryś
@Avasil
@alexandru yes, how can I help you? :D
Alexandru Nedelcu
@alexandru
:)
On that Dotty PR I'm getting a couple of weird compiler warnings, as if the compiler used is Scala 2, but it's not an actual error, or reported as a warning for that matter. It's as if a separate Scala 2 compiler is executed on that code.
.../monix-execution/jvm/src/main/scala_3.0/monix/execution/atomic/Atomic.scala:80: error: ; expected but final found
  inline final def transformAndExtract[U](inline cb: (A) => (U, A)): U = {
         ^
.../monix-execution/jvm/src/main/scala_3.0/monix/execution/atomic/AtomicNumber.scala:31: error: ; expected but final found
  inline final def `-=`(value: A): Unit = subtract(value)
         ^
.../monix-execution/shared/src/main/scala_3.0/monix/execution/compat.scala:42: error: ; expected but type found
    opaque type Flag = Long
         ^
Any ideas why? Is this the fault of a plugin or something?
I asked Lars too, he has no idea.
This is not doing any sort of cross compilation. I'm just doing executionJVM/compile after ++3.0.0-RC3.
Piotr Gawryś
@Avasil
I have no clue but I'm also getting these logs
Alexandru Nedelcu
@alexandru
I might have figured it out.
Or not. It's really weird, those warnings only show up when you do Test/compile, not Compile/compile
Alexandru Nedelcu
@alexandru
Btw, in cases like these I don't think the inline is worth it, as the JVM is more than capable of doing it ...
final def apply(): A = get()

Also ...

inline def transformAndExtract[U](cb: (A) => (U, A)): U

Similarly, this isn't useful unless the cb function parameter itself is inlined in the body of this method. And for that I think cb itself needs an inline annotation too.

inline def transformAndExtract[U](inline cb: (A) => (U, A)): U

Not absolutely sure, this is what I remember.

Piotr Gawryś
@Avasil
I think you're right
Alexandru Nedelcu
@alexandru
I'm actually thinking of getting rid of all inlining macros for Scala 2.13.x (e.g. in Atomic).
The maintenance burden isn't worth it, it was a mistake introducing them.
Oleg Pyzhcov
@oleg-py
one cannot resist being fancy
and macros are very fancy :D
but I'm down to have them yeeted
Alexandru Nedelcu
@alexandru

@Avasil I don't understand what's going on here:

[error] monix-eval: Failed binary compatibility check against io.monix:monix-eval_2.13:3.3.0! Found 6 potential problems
[error]  * static method apply(Boolean,Int,Int)monix.eval.tracing.PrintingOptions in class monix.eval.tracing.PrintingOptions does not have a correspondent in current version
[error]    filter with: ProblemFilters.exclude[DirectMissingMethodProblem]("monix.eval.tracing.PrintingOptions.apply")
[error]  * method copy(Boolean,Int,Int)monix.eval.tracing.PrintingOptions in class monix.eval.tracing.PrintingOptions does not have a correspondent in current version
[error]    filter with: ProblemFilters.exclude[DirectMissingMethodProblem]("monix.eval.tracing.PrintingOptions.copy")
[error]  * synthetic method copy$default$1()Boolean in class monix.eval.tracing.PrintingOptions does not have a correspondent in current version
[error]    filter with: ProblemFilters.exclude[DirectMissingMethodProblem]("monix.eval.tracing.PrintingOptions.copy$default$1")
[error]  * synthetic method copy$default$2()Int in class monix.eval.tracing.PrintingOptions does not have a correspondent in current version
[error]    filter with: ProblemFilters.exclude[DirectMissingMethodProblem]("monix.eval.tracing.PrintingOptions.copy$default$2")
[error]  * synthetic method copy$default$3()Int in class monix.eval.tracing.PrintingOptions does not have a correspondent in current version
[error]    filter with: ProblemFilters.exclude[DirectMissingMethodProblem]("monix.eval.tracing.PrintingOptions.copy$default$3")
[error]  * method apply(Boolean,Int,Int)monix.eval.tracing.PrintingOptions in object monix.eval.tracing.PrintingOptions does not have a correspondent in current version
[error]    filter with: ProblemFilters.exclude[DirectMissingMethodProblem]("monix.eval.tracing.PrintingOptions.apply")
[error] stack trace is suppressed; run last evalJVM / mimaReportBinaryIssues for the full output

In the Dotty PR. The PrintingOptions definition hasn't changed. The Scala version hasn't changed either.

Ah shit, it might be the -Xsource:3 I added.
Jasper Moeys
@Jasper-M
yes probably related to private case class contructors
Alec Zorab
@AlecZorab
is there any prior art on something that looks like ReplaySubject but it caches to disk? I can see that I can probably just mangle ReplaySubject, but I don't feel like I'm going to be the first person who's wanted to do this
Alexandru Nedelcu
@alexandru
We don't have any disk caching, but would be cool to know what you're thinking of, or the implementation you come up with.
Alexandru Nedelcu
@alexandru

The Scala 3 (Dotty) PR is ready for review:

monix/monix#1323