From-text: type class to convert from Text
Bodigrim:
At the moment none of them provide conversions from
TexttoOsPath.
Oh great, it’s that discussion from two years ago:
POSIX file paths can contain any sequence of bytes as long as only a small set of expectations are met (per POSIX spec chapter 6.1).
OsPathisOsString(per the doc), so encodingOsPathunder POSIX therefore only makes sense if we assume some locale;Inferring user’s locale is a messy process that could well fail (per Fixing 'FilePath' in Haskell · Hasufell's blog);
Using
IsStringto convert to UTF-8 is not total, UTF-8 does not allow surrogate code points.
Therefore:
filepathrecommends and is structured around blindly assuming UTF-8 under POSIX, addressing (2) and (3);There is no
IsString OsPathinstance, citing (4).
And since unlawful IsString instances are tolerated within the ecosystem (in e.g. bytestring and text), IsString OsString makes total sense.
Can we just do the “OsPath is WTF-8/UCS2LE” thing I proposed two years ago instead of whatever this is?
Discussion in the ATmosphere