
Hi
So what's better?
- use an ADT (correct and portable by construction), convert to String when calling the IO library
- fumble with Strings, use an unholy mix of specialized and general functions, trip over a corner case
Or provide an ADT, demand people marshal to and from this ADT and not just cheat and use the string directly? Unfortunately people are lazy, I am one of them...
We should just wrap the old API, filePathToString any parameters and liftIO the function while we're at it.
How about class FilePathLike a where getRealFilePath :: a -> String Then convert readFile etc. to take a FilePathLike, rather than a filepath? I'd be happy with that, and then you can write an ADT and pin down all the exact details, and the end user can then pick whatever they want to use.
- declare that Unix uses Unicode too, take the appropriate conversion from the locale Unfortunately this is wrong, and will give the wrong answers.
- parameterize the FilePath ADT on the character type, you get (FilePath Word16) on Windows (which uses UCS-2, not UCS-4 and not UTF-16) and (FilePath Word8) on Unix; provide conversions from/to (FilePath String). Windows doesn't use UTF-16, NTFS does. FAT doesn't. And what about the Samba drive I have mounted under Windows?
Thanks Neil