Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Unix.walk or equivalent #490

Open
c-cube opened this Issue · 7 comments

3 participants

@c-cube
Owner

I'm not sure whether it exists already, but an equivalent of python's os.walk would be very interesting for scripting in OCaml. I could implement it maintainers think it's useful.

@gasche
Owner

Why not; there is an interesting, non-trivial logic to avoid looping endlessly in case of cyclic symbolic links. I'm not sure whether we'd want to return a sequence of directories, as Python's function does, or rather a tree (which can easily be turned into a sequence afterwards) -- I'd go for the tree interface.

@c-cube
Owner

that's an interesting idea; it could even be a kind of lazy tree (similar to BatSeq) for early termination. I like it.

@gasche
Owner

OCamlbuild has a directory-walking implementation, which is amusingly named "slurp". Do have a look at slurp.{ml,mli}. Couldn't we just reuse this implementation?

@hcarty

This looks similar to/could be built rather simply on top of the find function in FileUtils. How much overlap do we want between these libraries? Should something be used from there?

@c-cube
Owner

Indeed, it even looks more powerful thanks to the test system! Maybe a batteries-friendly interface to FileUtils would be nice, then. Something like wrapping FileUtil.find in an Enum?

Actually that's an interesting global design issue: should we make wrappers around other libraries (lwt for instance?) with optional modules, that keep batteries quite small and still integrate it nicely with the rest of the OCaml ecosystem? Opam's conditional compilation would help keeping this sane.

@hcarty

This may be getting off-topic for a github bug discussion - but what is the proper approach for wrapping an external library for Batteries-friendly use? There are a few which would be nice to have in a Batteries-friendly form (Calendar, FileUtils, Lwt).

@c-cube
Owner

@hcarty let's move it to the mailing list if you want.
edit: done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.