[Haskell-cafe] RE: ANN: System.FilePath 0.9
Andrew Pimlott
andrew at pimlott.net
Fri Jul 28 19:27:56 EDT 2006
On Thu, Jul 27, 2006 at 09:59:37PM +0200, Udo Stenzel wrote:
> Andrew Pimlott wrote:
> > After all, the trailing slash has no real
> > meaning for any intermediate processing you might do.
>
> Here I beg to differ. I'd expect:
>
> *> setFileName "foo" "bar" == "bar"
> *> setFileName "foo/" "bar" == "foo/bar"
>
> In fact, that's consistent with the current documentation, because
>
> *> getFileName "foo" == "foo"
> *> getFileName "foo/" == ""
I have to disagree with that. First of all, "" is not a filename; if
you mean that "foo/" has no filename, it makes much more sense to use
something like a Maybe type. Second, "foo" is just as good a directory
as "foo/" to the system, and they both denote the same filesystem object
(the object with the name "foo" in the current directory), so it doesn't
make sense to me for path operations to distinguish them. Maybe the
second point is philosophical. But if you wish to make the distinction,
at least provide an operation that lets me force a path to be treated
"file-wise" or "directory-wise".
> > readPath :: String -> (Path, Bool {- trailing delimiter -})
> > showPath :: Path -> String
> > showPathTrailingSlash :: Path -> String
> >
> > This is far simpler than trying to figure out what the slash means for
> > every path operation.
>
> It's also far uglier... besides, it isn't about the slash, it is about
> the difference between file and directory.
Filesystems are ugly. :-) And it is about the slash: "foo" can be a
directory.
Andrew
More information about the Haskell-Cafe
mailing list