Skip to content

Add FilePath -> String decoder

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)

This functionality is implemented in the attached patch; 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

Trac metadata
Trac field Value
Version 6.10.4
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component libraries/base
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information