[Haskell] System.FilePath survey
Ben Rudiak-Gould
Benjamin.Rudiak-Gould at cl.cam.ac.uk
Tue Feb 7 11:25:35 EST 2006
Bulat Ziganshin wrote:
> Hello Ben,
>
> BRG> Also, getArgs should return [ADT].
>
> getLine also shoukd return ADT - just for case when user supplied a
> filename? :) and "++" operation should return ADT too? :)
The point is that different things are natively handled in different formats
under different OSes, e.g.
Posix NT Win9x
pathnames bytes UTF-16 locale
command line bytes UTF-16 locale
file contents bytes bytes bytes
pipes/sockets bytes bytes bytes
File and streams should be read and written as bytes (octets) because that's
the interface provided by every supported OS -- and not for any other
reason. Pathnames and the command line should have the same representation
in Haskell because they have the same representation in every supported OS,
and one very frequently needs to convert between them. Using different types
would make no sense, as far as I can tell. Ashley Yakeley says that he wants
to parse options in his command-line arguments, and so do I, but I also want
to find out the extension of a filename, and whether it's a backup file
(ends with '~'), and whether it contains non-ASCII characters, and so on.
Interconversion is necessary in either case, and the issues involved are the
same, so in my opinion they should be handled together.
Actually, there's one extra issue with the command line: in Posix it's a
list of strings, while in Windows it's just one string. Very few if any
Windows applications do their own command line parsing. NT provides a
function CommandLineToArgvW, but I don't know what algorithm it uses.
-- Ben
More information about the Libraries
mailing list