[Haskell] Reading a directory tree
Andrew Pimlott
andrew at pimlott.net
Mon Jun 28 13:48:31 EDT 2004
On Mon, Jun 28, 2004 at 11:08:38AM -0400, Isaac Jones wrote:
> This thread makes me want to mention that I'm starting to put together
> a little library of useful path-based functions (I started it based on
> OS.Path in Python).
(These are hastily conceived comments; maybe I can refine later.)
Having used Perl's File::Spec, to which OS.Path seems pretty similar, I
hate it. I always end up going through contortions splitting, doing
list operations, and joining. Please don't make me mix path operations
with list operations to do simple things, like take two components off
a path and adding "foo":
let newPath = appendComponents ["foo"] (ancestor 2 oldPath)
Whether oldPath, newPath are FilePath's or some more structered
representation, I don't really care, though I would lean towards the
second.
You don't seem to address the problem of volumes or drives (a:, c:). I
don't think you can punt this.
Be very explicit in the documentation about what your model of a path
is. Most libraries implictly rely upon some form of unix conventions,
without pinning them down. I find it hard to use File::Spec without
trial and error.
Be very explicit about operations on the abstract path versus operations
that use the filesystem. Of course the type helps in Haskell, but I
think this should further be an organizing principle of the library.
Finally, it's probably not acceptible for a "production library" to
hard-code the path separator by platform. There will have to be a way
to manipulate foreign paths.
To be frank, I wouldn't start with OS.Path or any other library I've
seen.
Andrew
PS. Please Cc: me.
More information about the Libraries
mailing list