[Haskell-cafe] Re: File path programme

Peter Simons simons at cryp.to
Wed Feb 2 09:06:50 EST 2005


Glynn Clements writes:

 >> Well, there is a sort-of canonic version for every path;
 >> on most Unix systems the function realpath(3) will find
 >> it. My interpretation is that two paths are equivalent
 >> iff they point to the same target.

 > I think that any definition which includes an "iff" is
 > likely to be overly optimistic.

I see your point. I guess it comes down to how much effort
is put into implementing a realpath() derivate in Haskell.


 > Even so, you will need to make certain assumptions. E.g.
 > older Unices would allow root to replace the "." and ".."
 > entries; you probably want to assume that can't happen.

My take on things is that it is hopeless to even try and
cover all this weird behavior. I'd like to treat paths as
something abstract. What I'm aiming for is that my library
can be used to manipulate file paths as well as URLs,
namespaces, and whatnot else; so I'll necessarily lose some
functionality that an implementation specifically designed
for file paths could provide. If you want to be portable,
you cannot use any esoteric functionality anyway.


 > There are also issues of definition, e.g. is "/dev/tty"
 > considered "equivalent" to the specific "/dev/ttyXX"
 > device for the current process?

No, because the paths differ. ;-)

Peter



More information about the Haskell-Cafe mailing list