[Haskell-cafe] System.FilePath, Request for comments

David Roundy droundy at darcs.net
Sat Jul 1 09:17:07 EDT 2006

On Thu, Jun 29, 2006 at 11:14:46PM +0100, Brian Hulley wrote:
> Neil Mitchell wrote:
> >The other important point regarding ADT's is what is a FilePath and
> >what is a String? If I set the extension of a FilePath, is that
> >extension itself a FilePath or a String? What if I set the drive or
> >the filename? Is a filename on its own a FilePath? Even though it
> >doesn't correspond to a file, because its lost its context/directory
> >and therefore cannot be used?
> I wonder if it would be better to have an ADT for strings rather than 
> FilePaths (to solve the issues above and also for general use in other 
> Haskell libs).

An ADT for strings wouldn't address the issue that on posixy systems,
a filepath isn't a unicode string, while an ADT for FilePaths could
solve that problem.  And that's a significant problem, since otherwise
the standard libraries would prevent certain utilities from being
written in Haskell (e.g. one that computes the number of files in a

My leaning (and you could search the archives for a post on the
subject by Ian Lynagh) is to have a class rather than an ADT for
filepaths.  It makes the type signature of all file IO functions more
complicated, but means that you could use "real" strings,
Data.ByteStrings, etc as filepaths.
David Roundy

More information about the Haskell-Cafe mailing list