Proposal #3456: Add FilePath -> String decoder

Johan Tibell johan.tibell at gmail.com
Wed Aug 26 04:38:30 EDT 2009


Hi Judah,

A few comments:

- I would spell 'filePathToString' as just 'toString' and use the
module system to provide a namespace (i.e. stick it in
System.FilePath).

- A function that takes the encoding as a parameter instead of
fetching it from the current locale seems more useful. However,
creating such a function is a bit problematic since passing an
explicit encoding doesn't really make sense on Windows where a path is
already represented as Unicode. Perhaps the only solution is to have
System.FilePath.Posix.toString and System.FilePath.Windows.toString
with different type signatures.

- As long as FilePath is just a type synonym the function is unsafe as
it's equivalent to decodeWithCurrentLocale :: String -> IO String
which fails if the argument string is actually used to store Unicode
data (rather than bytes stored as code points < 256). This is probably
intentional but it might be worth mentioning it in the Haddock
documentation.

Cheers,

Johan


More information about the Libraries mailing list