Krasimir Angelov wrote:
For example, what should splitFileName "/" (unix) or splitFileName "." be, and why? I can't think of any answers that are consistent with the type (FilePath -> (String, String)).
In the current implementation: splitFileName "/" == ("/", "") splitFileName "." == (".", ".")
The latter is OK, but not the former; "" isn't a valid filename. splitFileName "/" == ("/", ".") would be more reasonable, insofar as chdir()ing to the first element then accessing the second will have the expected behaviour. This leads to a more general question: what should splitFileName "/foo/bar" (where bar is a directory) equal? Both: splitFileName "/foo/bar" == ("/foo", "bar") and: splitFileName "/foo/bar" == ("/foo/bar", ".") are defensible in the sense that reversing the operation with joinFileName will refer to the same object as the original path. The former is probably the "expected" result, although the latter is consistent with the suggested handling of "/". Essentially, the former assumes that the pathname refers to an object (file or directory) which resides within a directory, which isn't really true of the root directory. -- Glynn Clements <glynn@gclements.plus.com>