[Haskell-cafe] File path programme

Mark Carroll mark at ixod.org
Thu Jan 20 15:17:15 EST 2005


I tried writing a little command-line utility to find the relative path of
one thing from another thing (with Unix-like systems in mind). For example,

$ ./pathfromof /etc/init.d/ /etc/X11/XF86Config-4
../X11/XF86Config-4
$ ./pathfromof /tmp/baz/ /tmp/foo/
.
$ ls -l /tmp/baz
lrwxr-xr-x  1 markc markc 8 2005-01-20 12:01 /tmp/baz -> /tmp/foo

It turned out surprisingly complex, though, and doesn't feel very neat or
tidy at all, nor is it very portable given that I couldn't find generic
library functions for manipulating bits of filepaths. Anyhow, it's at
http://www.chiark.greenend.org.uk/~markc/PathFromOf.hs and may yet have
egregious bugs.

It seems to me like it could certainly be improved in various ways. If
anyone has any thoughts, as to how I could improve my style, make more use
of standard libraries, etc., I'd certainly appreciate them.

Thanks,
        Mark


More information about the Haskell-Cafe mailing list