Giter Site home page Giter Site logo

Pipe last implementation about promise HOT 2 CLOSED

aantron avatar aantron commented on May 18, 2024
Pipe last implementation

from promise.

Comments (2)

lessp avatar lessp commented on May 18, 2024 3

Thanks for always providing such elaborate and thoughtful answers!

I had entirely forgotten about let-operators pretty much solving this completely! Personally, I can see how it makes sense to wait, that considered. 🙂

from promise.

aantron avatar aantron commented on May 18, 2024 1

It's feasible to do, but I'd be concerned about increasing bundle size on the JS side, for a feature that isn't a "primary" concern for JS-only work. For now, I added a PipeFirst module (you may have already seen it). To write code that works on both native and JS with it, you can do:

open Promise.PipeFirst;

On JS, the module is empty, because we want to forward to BuckleScript's operator:

promise/src/js/promise.rei

Lines 230 to 231 in 6b9ff51

module PipeFirst: {
};

On native, the module defines the operator for unary functions (it's the desugared syntax, but -> maps to it):

module PipeFirst: {
let (|.): ('a, 'a => 'b) => 'b;
};

This is good enough for most uses, which are partially-applied binary functions from Promise.

Obviously, using -> a lot on mostly-native code is going to stick out. I don't know yet what to do about that :/ I figured this library's main contribution is to JS, rather than to native, so it's best to follow BuckleScript conventions.

Note that the pipe operators might become less important over time, as people switch more and more conclusively to OCaml 4.08+ on the native side, and BuckleScript releases a Reason with let* support. Then, let* syntax might replace many uses of the pipe operator with promise functions (#52).

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.