Giter VIP home page Giter VIP logo

Comments (4)

ncthbrt avatar ncthbrt commented on May 25, 2024 1

I agree with this sentiment. Just wanted to make it clear that if this is a limitation of repromise, it should be thoroughly documented so that binding authors are aware of the possible pitfalls.

from promise.

aantron avatar aantron commented on May 25, 2024 1

@ncthbrt There is now some initial documentation about this in Repromise's new doc site.

from promise.

aantron avatar aantron commented on May 25, 2024

Indeed, the discussion about that is here: rescript-lang/rescript-compiler#2345 (comment).

The TL;DR summary is: fixing and not fixing this issue both have negative implications for interop with JavaScript, and for now my guess is that it is better not to fix it, however it is only a guess, so please give any information to the contrary (or in support) that you come across.


More detail:

  • Functions like 'a => Js.Promise.t('a) should be pretty rare, and I think most of them will be promise manipulators (like Promise.resolve, the most obvious function with this type). We don't want people to use these functions from JS anyway, because they are inherently broken. For example, in the case of Promise.resolve, we are replacing it with repromise's Repromise.resolve. That suggests that it is not very important to fix this.
  • Fixing it makes interop between repromise and JS promises non-trivial, as one now has to convert repromises to JS promises before passing them to JS, and wrap promises that come back from JS. So there is a definite penalty to fixing this.

For now, I think it's better to

  1. Push the burden of dealing with functions like 'a => Js.Promise.t('a) to bindings authors. If an author encounters such a function, we should give them tools like runtime checks for whether the argument is a repromise or not, so they can manually make the binding sound.
  2. Ask people to let us know if any of the assumptions above are wrong, in particular if 'a => Js.Promise.t('a) is something that occurs commonly in functions people want to bind, and is something we really need to give first-class support for.

And, of course, all of this should be loudly documented as repromise takes shape :)

I want to also point out that none of the above is any way "final." Repromise is an exploration project, we will learn and adapt as we go.

from promise.

ncthbrt avatar ncthbrt commented on May 25, 2024

Awesome. :)

from promise.

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.