[Haskell-cafe] RE: ANN: System.FilePath 0.9
u.stenzel at web.de
Fri Jul 28 20:59:06 EDT 2006
Andrew Pimlott wrote:
> On Thu, Jul 27, 2006 at 09:59:37PM +0200, Udo Stenzel wrote:
> > In fact, that's consistent with the current documentation, because
> > *> getFileName "foo" == "foo"
> > *> getFileName "foo/" == ""
> I have to disagree with that.
No, you don't. That's the current behaviour of Neil Mitchell's
System.FilePath 0.9 according to the haddockumentation. There isn't
much point in disagreeing about observable facts, is there?
> First of all, "" is not a filename;
Most certainly it isn't. Which is all the more reason not to like the
current design. An empty filename just isn't the same as no filename.
> if you mean that "foo/" has no filename, it makes much more sense to use
> something like a Maybe type.
It does very much. In fact, I don't deem getFileName to be an essential
function when a simple pattern match would do the same thing. "foo/"
really doesn't have a file name, as it very explicitly names a
> Second, "foo" is just as good a directory
> as "foo/" to the system
...unless you have both (think Reiser4) or you want to create the file
(I think, but I'm not sure). However, what's the point in being
ambiguous when we can be explicit? Sometimes there is a difference,
libraries and tools shouldn't gloss over that without consideration.
> 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".
WTF?! A path names either a directory or a file. We might have some
operations that accept file names instead of path names. What's there
to be treated? Being explicit about the distinction makes any ambiguity
> Filesystems are ugly. :-)
So are microprocessors. We can still have a nice programming language,
and we can also have a nice filesystem language.
> And it is about the slash: "foo" can be a directory.
No, it still isn't. We can distinguish between "Directory (but not
file, fifo, character or block special)" and "anything (if in doubt, not
directory)", which is an essential semantic distinction and not just the
accidental presence of a slash (or backslash or colon or whatever
Also, parsing paths _once_ and printing them _once_ but doing everything
else by operating on their logical structure makes specifying any
intermediate operation a lot easier, if nothing else. If this thread
shows anything, then it is that specifying path operations is harder
Structure is _nothing_ if it is all you got. Skeletons _spook_ people if
they try to walk around on their own. I really wonder why XML does not.
-- Erik Naggum
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Size: 189 bytes
Desc: Digital signature
Url : http://www.haskell.org//pipermail/haskell-cafe/attachments/20060729/86108e6d/attachment.bin
More information about the Haskell-Cafe