makeRelative
wren ng thornton
wren at freegeek.org
Sun Sep 30 20:26:46 CEST 2012
On 9/30/12 10:24 AM, Ben Millwood wrote:
> 2. surely this issue can be avoided by using something like
> System.Directory.canoncalizePath before calling makeRelative. I think
> doing things that way would separate the pure and IO parts of the
> algorithm much better, and allow users to ignore the possibility of
> symlinks when that was appropriate for their use.
Indeed. While it's important to be able to capture correct POSIX
behavior, there's also plenty of room for legitimate uses of naive
relative paths. In particular, the former is more important when
accessing the filesystem, whereas the latter is more important when
generating files[1].
So long as the documentation includes das blinkenlights, to ensure that
users know which behavior they're getting, I think it's fine to offer
the naive implementation. If folks consider it "unsafe" enough to
warrant name changes, we could always:
canoncalizePath :: Path -> IO Path
naiveMakeRelative :: Path -> Path -> Path
makeRelative x y = do
x <- canoncalizePath x
y <- canoncalizePath y
return $! naiveMakeRelative x y
[1] Because you know the filesystem structure you'll be generating, so
you know whether this will be an issue. And because the files you'll be
generating don't yet exist and so can't be cannonicalized, as others
have mentioned.
--
Live well,
~wren
More information about the Libraries
mailing list