Proposal #3456: Add FilePath -> String decoder

Judah Jacobson judah.jacobson at gmail.com
Sun Aug 23 12:27:15 EDT 2009


Currently, FilePaths on POSIX systems are represented as raw bytes in
a String.  When this last came up on the mailing list, the general
consensus was to make FilePath an abstract datatype representing paths
as Strings on Windows and raw bytes on POSIX systems.  However, such a
change is sure to break some existing code.

As a small step towards that goal, I propose adding the following two
functions to the System.IO module:

filePathToString :: FilePath -> IO String
getFilePathToStringFunc :: IO (FilePath -> String)

I've implemented those functions in a patch attached to the trac
ticket.  Haddock docs are here:
http://code.haskell.org/~judah/new-io-docs/System-IO.html#v%3AfilePathToString

On POSIX those functions decode according to the current locale, so
they ought to be in the IO monad.  I think that the latter function
will be easier to integrate into existing pure code.

On Windows, those functions are just `return` and `return id`,
respectively, since GHC already treats FilePaths as Strings on that
platform.

Discussion deadline: September 9
Ticket: http://hackage.haskell.org/trac/ghc/ticket/3456

Best,
-Judah


More information about the Libraries mailing list