Abstract FilePath Proposal

Neil Mitchell ndmitchell at gmail.com
Tue Jun 30 09:25:02 UTC 2015

Hi David,

> One tiny amendment to a comment(!) in the non-normative(!) code in Phase 3:
> data WindowsFilePath = WFP ByteArray# -- UTF16 data
> If a Windows file path is valid UTF-16 then it is displayed as such in the
> GUI, but if not it's still a legal file path. It really is just wchar_t[]
> data.

Thanks for bringing this up. It's tricky - I think in practice:

toFilePath x = WPF (encodeStringAsUTF16 x)

But the data in WPF will be treated as UCS2 (aka wchar_t) when passing
to the API calls, so it's really both. While on Windows NT it really
was UCS2, but Win 7 it's always treated as UTF16 in the GUI, so that
seems to be consistent with what people expect and ensures we don't
throw away information when converting to/from FilePath. Given it
seems you are quite knowledgeable in this area, please shout if that
seems misguided!

To all the people who are worried about breakage, I can guarantee this
will cause breakage. It's a sad fact, and certainly the main negative
to this proposal. I was on the fence initially when hvr suggested this
change to me, but was convinced by performance and correctness.
Whether the Haskell community as a whole thinks that makes it worth it
is why it's a proposal. If anything, I'm concerned by the lack of
people saying -1, please don't break my code...

Thanks, Neil

More information about the Libraries mailing list