Git Product home page Git Product logo

Comments (7)

talex5 avatar talex5 commented on June 13, 2024

For Buf_read, the names were chosen to be compatible with Angstrom's names; e.g. https://github.com/inhabitedtype/angstrom/blob/5536d1da71469b49f37076beb5f75d34f448da5e/lib/angstrom.mli#L89.

I think Buf_write.printf would be a great addition (PRs welcome).

The use of Filename.concat in path.ml is a bug - it will use the wrong separator on Windows. There is a Path.split that might be useful for you. Calling it in a loop will get all the components. That might be a useful convenience function to add indeed (along with basename and dirname).

As an alternative to using a GADT, you can also cast to a concrete type: see https://github.com/ocaml-multicore/eio#casting

from eio.

mbarbin avatar mbarbin commented on June 13, 2024

Hi @talex5.

I did some initial exploration based on your answer here. If you think some bits are going the right direction (printf, components, basename and dirname) I can try and create some PRs out of it.

Re: casting.

As an alternative to using a GADT, you can also cast to a concrete type: see https://github.com/ocaml-multicore/eio#casting

Sorry I missed that section of the doc. This is spot on and I ended up preferring this style. Thanks! While writing the cast I wondered whether it would make sense to offer some canonical type alias in eio to simplify usage. I explored it a bit here, please let me know your thoughts.

Re: api compatibility. Thanks for pointing out the Angstrom constraint. It occurred to me that with what's already exposed by Buf_read and Buf_write, many things can be done in the user land depending on people's need, so I'm happy to do some exploration as third party libraries for now (example here). Thank you!

from eio.

talex5 avatar talex5 commented on June 13, 2024

Using primes for the generic types looks interesting. I didn't add them originally as there are so many types already.

I think basename etc should just be e.g. snd (split t). Why is extra logic needed?

from eio.

mbarbin avatar mbarbin commented on June 13, 2024

Re: basename

I expect the domain for basename and dirname to be any valid Eio.Path.t', thus my inclination was for their types to be:

  val basename : _ Eio.Path.t -> string
  val dirname : _ Eio.Path.t -> string

If you limit their implementation to the domain where split is defined, you'd end up with a string option in the returned type (thus the extra logic in the None case).

For the behavior, I based it on what I witness was the behavior of unix utils basename and dirname when typed in a terminal. For example:

$ dirname ''
.

You can have a look at the test cases I looked at here

I plan on creating separate PRs for the different things we talked about here, that way we'll be able to further discuss options there. Thank you!

from eio.

mbarbin avatar mbarbin commented on June 13, 2024

Re: basename in PR #648

from eio.

mbarbin avatar mbarbin commented on June 13, 2024

Re: type-aliases: I couldn't think of a technic that offers the same potential benefits without adding complexity and more types. I'll continue experimenting with it.

I believe my feedback is entirely covered at this point (thank you @SGrondin for #652 !), I'm happy to close this issue.

Thank you.

from eio.

talex5 avatar talex5 commented on June 13, 2024

(Buf_write.printf was added in #655)

from eio.

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.