[Haskell-cafe] FilePath handling [Was: Writing binary files?]

Glynn Clements glynn.clements at virgin.net
Wed Sep 15 11:58:02 EDT 2004


Henning Thielemann wrote:

> Udo Stenzel wrote:
> 
> > The same thoughts apply to filenames.  Make them [Word8] and convert
> > explicitly.  By the way, I think a path should be a list of names (that
> > is of type [[Word8]]) and the library would be concerned with putting in
> > the right path separator.  Add functions to read and show pathnames in
> > the local conventions and we'll never need to worry about path
> > separators again.
> 
> I even plead for an abstract data type FilePath which supports operations
> like 'enter a directory', 'go one level higher' and so on.

Are you referring to "pure" operations on the FilePath, e.g. appending
and removing entries? That's reasonable enough. But it needs to be
borne in mind that there's a difference between:

	setCurrentDirectory ".."
and:
	dir <- getCurrentDirectory
	setCurrentDirectory $ parentDirectory dir

[where parentDirectory is a pure FilePath -> FilePath function.]

if the last component in the path is a symlink.

If you want to make FilePath an instance of Eq, the situation gets
much more complicated.

-- 
Glynn Clements <glynn.clements at virgin.net>


More information about the Haskell-Cafe mailing list