{
  "$type": "site.standard.document",
  "bskyPostRef": {
    "cid": "bafyreiaev5q4rlla4mfz2hvox7gjwfs7fj2dod3hvtost6cyx6ncsesvwi",
    "uri": "at://did:plc:pi6woz4d47bkuws673w2il2r/app.bsky.feed.post/3mmj6p3hdgsw2"
  },
  "path": "/t/from-text-type-class-to-convert-from-text/14150#post_3",
  "publishedAt": "2026-05-23T08:27:12.000Z",
  "site": "https://discourse.haskell.org",
  "tags": [
    "discussion",
    "POSIX spec chapter 6.1",
    "the doc",
    "Fixing 'FilePath' in Haskell · Hasufell's blog",
    "“OsPath is WTF-8/UCS2LE” thing"
  ],
  "textContent": "Bodigrim:\n\n> At the moment none of them provide conversions from `Text` to `OsPath`.\n\nOh great, it’s that discussion from two years ago:\n\n  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).\n\n  2. `OsPath` is `OsString` (per the doc), so encoding `OsPath` under POSIX therefore only makes sense if we assume _some_ locale;\n\n  3. Inferring user’s locale is a messy process that could well fail (per Fixing 'FilePath' in Haskell · Hasufell's blog);\n\n  4. Using `IsString` to convert to UTF-8 is not total, UTF-8 does not allow surrogate code points.\n\n\n\n\nTherefore:\n\n  * `filepath` recommends and is structured around blindly assuming UTF-8 under POSIX, addressing (2) and (3);\n\n  * There is no `IsString OsPath` instance, citing (4).\n\n\n\n\nAnd since unlawful `IsString` instances are tolerated within the ecosystem (in e.g. `bytestring` and `text`), `IsString OsString` makes total sense.\n\n* * *\n\nCan we just do the “OsPath is WTF-8/UCS2LE” thing I proposed two years ago instead of whatever this is?",
  "title": "From-text: type class to convert from Text"
}