Git Product home page Git Product logo

Comments (8)

aantron avatar aantron commented on May 25, 2024

For the specific case of file permissions, it's superfluous to have async and sync ones – there is nothing about file permissions that is synchronous and asynchronous. Indeed, the types are identical in both Unix and Lwt_unix. IMO introducing these constructors for them hurts composability, and also misleads the user to think there is actually a difference.

So, I'd say to revert the second arguments to be file_perm (int) again.

from lwt-node.

kennetpostigo avatar kennetpostigo commented on May 25, 2024

@aantron I hear you, of the newly added constructors is file_descr the only one where there is a distinction? If so should I remove all other?

from lwt-node.

aantron avatar aantron commented on May 25, 2024

Maybe dir_handle needs the distinction, otherwise I think not. But you will only really know when trying to create the rest of the API around them.

from lwt-node.

kennetpostigo avatar kennetpostigo commented on May 25, 2024

Gotcha, I guess I should really just cross reference both Unix/Lwt_unix whenever new types are required by the functions from Unix/Lwt_unix in reason-node and check if their representations differ. Also I may just alias them just like Lwt did instead of GADT just for simplicity sake. Fun using GADT tho :)

from lwt-node.

aantron avatar aantron commented on May 25, 2024

That sounds like a good idea, though sometimes you may want an artificial distinction for the sake of your API. For example, even if Unix and Lwt_unix had the same representations of fds, you might still want to introduce a phantom type parameter in your API, or use two different types, if you want whether each fd is sync or async to be known to the type system.

from lwt-node.

kennetpostigo avatar kennetpostigo commented on May 25, 2024

@aantron when this is the case and the developer is using a function that has a file_descr argument, the type must be exposed for them to use right? Theres no way around that? Similar to what happened in the mkdir example

from lwt-node.

aantron avatar aantron commented on May 25, 2024

The type's name, or both name and definition? The type's existence (name) has to be exposed, yes, but you should be able to leave the definition abstract. For comparison, Unix.file_descr and Lwt_unix.file_descr are both abstract.

from lwt-node.

kennetpostigo avatar kennetpostigo commented on May 25, 2024

@aantron well if it's abstract wouldn't the value constructors not be accessible?

from lwt-node.

Related Issues (4)

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.