Giter VIP home page Giter VIP logo

Comments (7)

puffnfresh avatar puffnfresh commented on August 18, 2024

Yes. This is tricky.

from fantasy-land.

kennknowles avatar kennknowles commented on August 18, 2024

Importing discussion with @Twisol about equality and the event loop.

My understanding of what has been said:

  • Promises/A+ forbids the argument to then to be called synchronously.
  • Depending on the notion of equality, the monad laws may require the argument to then to be called synchronously.
  • @Twisol has experienced challenges that led to distinguishing Present and Future promises, in order to have predictable ordering of side effects.

My suggestion is to work out a notion of equality for promises that allows the laws to hold regardless of synchrony, and to order side effects with the usual concurrency control mechanisms. The notion of equality must not forbid such mechanisms from working - waiting on a mutex before delivering a value should be equivalent to delivering it immediately.

The implication for Fantasy Land is simply that equality should be defined by the monad/functor/values in question, and that side effects remain up to the programmer to sort out.

from fantasy-land.

Twisol avatar Twisol commented on August 18, 2024

Just to clarify, you advocate pushing the issue of side-effects downstream to the individual monad implementations?

from fantasy-land.

kennknowles avatar kennknowles commented on August 18, 2024

Exactly.

from fantasy-land.

Twisol avatar Twisol commented on August 18, 2024

Okay. I don't really have a problem with that, but I would hate to see a monad implementation that didn't adequately address it somehow.

from fantasy-land.

kennknowles avatar kennknowles commented on August 18, 2024

I agree with the concern. In the case of promises + concurrency side effects the two are clearly intimately related so worth discussion in the docs for any implementation of promises.

But I would expect most monad implementations to pass the buck downstream to users, especially data-oriented monads such as List, Maybe, Either, or the free monad. Wouldn't make much sense to talk about side effects in those cases; hopefully programmers know what they are getting into when they use side-effects in a list comprehension (I do this all the time via knockout + underscore).

But I want to emphasize that this issue is a necessary discussion in all cases, even the very simple ones, because [1, 2, 3] === [1, 2, 3] is false, as is {inLeft: 1} === {inLeft: 1}

from fantasy-land.

Twisol avatar Twisol commented on August 18, 2024

That's fair. I think we should have a section of the spec on things that must be addressed somehow downstream, even if we don't prescribe a particular approach. These things seem to come up because of the imperative domain, and they can't be naively ignored.

from fantasy-land.

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.