Git Product home page Git Product logo

Comments (6)

austindd avatar austindd commented on June 27, 2024

Yeah, you're totally right. I think that's the right call. I want to say we inspected the values at runtime to see what they were under the hood, but it's probably irrelevant. Abstract types make sense.

from reason-nodejs.

yawaramin avatar yawaramin commented on June 27, 2024

Thanks Austin. I just realized that these constants are expected to be used as ints, e.g. from https://nodejs.org/dist/latest-v10.x/docs/api/fs.html#fs_fs_copyfile_src_dest_flags_callback:

flags is an optional integer that specifies the behavior of the copy operation. It is possible to create a mask consisting of the bitwise OR of two or more values (e.g. fs.constants.COPYFILE_EXCL | fs.constants.COPYFILE_FICLONE).

So the type of all flags would also need to be changed to Constants.t and also a logical-or operator (or function) would need to be added to allow doing bitmasks. But that is reasonably easy, e.g.

module Constants: {
  type t;
  ...
  let (||): (t, t) => t;
} = {
  type t = int;
  ...
  let (||)(t1, t2) = t1 lor t2;
};

from reason-nodejs.

austindd avatar austindd commented on June 27, 2024

On the other hand, if the constants are each instances of separate abstract types, then it's tricky to pattern match on them. And I can imagine use cases for pattern matching. What do you think?

from reason-nodejs.

yawaramin avatar yawaramin commented on June 27, 2024

Yeah you're right, that can also be solved by using a pri int type, since the docs do implicitly say that it should be an int.

from reason-nodejs.

austindd avatar austindd commented on June 27, 2024

from reason-nodejs.

yawaramin avatar yawaramin commented on June 27, 2024

Sure, I'll send a PR soon.

from reason-nodejs.

Related Issues (16)

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.