System.FilePath propsal (Was: Cabal feedback notes)

Glynn Clements glynn at
Wed Oct 27 05:00:14 EDT 2004

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?

	splitFileName "/foo/bar" == ("/foo", "bar")
	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

Glynn Clements <glynn at>

More information about the Libraries mailing list