External Publication
Visit Post

From-text: type class to convert from Text

Haskell Community [Unofficial] May 23, 2026
Source

Bodigrim:

At the moment none of them provide conversions from Text to OsPath.

Oh great, it’s that discussion from two years ago:

  1. 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).

  2. OsPath is OsString (per the doc), so encoding OsPath under POSIX therefore only makes sense if we assume some locale;

  3. Inferring user’s locale is a messy process that could well fail (per Fixing 'FilePath' in Haskell · Hasufell's blog);

  4. Using IsString to convert to UTF-8 is not total, UTF-8 does not allow surrogate code points.

Therefore:

  • filepath recommends and is structured around blindly assuming UTF-8 under POSIX, addressing (2) and (3);

  • There is no IsString OsPath instance, 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

Loading comments...