Git Product home page Git Product logo

Comments (3)

djspiewak avatar djspiewak commented on May 21, 2024

So, there is an idempotency check (specifically applied here). From a performance standpoint, I'm pretty sure AtomicBoolean is an order of magnitude faster than raw synchronization (especially when uncontested), but even beyond that, we could do even better with a method handle and a switch point if we really wanted to make it that fast.

The problem is that if IO doesn't do this, it either has to capture an ExecutionContext (in order to use reportFailure) or just swallow the error altogether, neither of which seem like particularly good solutions relative to the rest of the design.

But all that aside… I tend to agree that the law is too restrictive. It basically means that implementors can only implement their types in this way, and I don't think that's what we want to say. So I think you're right that we should remove the law and add it as a test specifically for IO.

from cats-effect.

alexandru avatar alexandru commented on May 21, 2024

Well, yeah, on top of Java 8 that getAndSet operation is pretty fast, using platform intrinsics and if you do it once "per program" it's not a problem. Also when dealing with say a Scala Promise, it has trySuccess baked in.

So yes, it's not IO's implementation I'm complaining about, but this law :-)

It would have been helpful to specify an Either in that law ... such that we could specify equivalence with raiseError(ex) or never. Such a law would still disallow blowing the current call-stack for example.

from cats-effect.

djspiewak avatar djspiewak commented on May 21, 2024

It would have been helpful to specify an Either in that law ... such that we could specify equivalence with raiseError(ex) or never. Such a law would still disallow blowing the current call-stack for example.

Hmm, that's an interesting idea, though I'm not sure how many implementation flaws that would actually catch. A bigger problem though is that the current Eq[IO[A]] implementation I'm using in the laws is unable to check equivalence with never. I haven't actually looked at how Monix's tests do that…

from cats-effect.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.