HORIZON HASKELLDocslts/ghc-9.10.x248f8f02026-10-05Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · 248f8f0 · 2026-10-05

Modulefilepath-1.5.4.0Haskell2010

System.OsPath.Internal

  • 11 values
  • Packagefilepath-1.5.4.0
  • Exports11
  • LanguageHaskell2010
  • LicenceBSD-3-Clause
  • SourceInternal.hs
valueencodeUtf :: MonadThrow m => FilePath -> m OsPath
#

Partial unicode friendly encoding.

On windows this encodes as UTF16-LE (strictly), which is a pretty good guess. On unix this encodes as UTF8 (strictly), which is a good guess.

Throws an EncodingException if encoding fails. If the input does not contain surrogate chars, you can use unsafeEncodeUtf.

valueencodeFS :: FilePath -> IO OsPath
#

Like encodeUtf, except this mimics the behavior of the base library when doing filesystem operations, which is:

  1. on unix, uses shady PEP 383 style encoding (based on the current locale, but PEP 383 only works properly on UTF-8 encodings, so good luck)

  2. on windows does permissive UTF-16 encoding, where coding errors generate Chars in the surrogate range

Looking up the locale requires IO. If you're not worried about calls to setFileSystemEncoding, then unsafePerformIO may be feasible (make sure to deeply evaluate the result to catch exceptions).

valuedecodeUtf :: MonadThrow m => OsPath -> m FilePath
#

Partial unicode friendly decoding.

On windows this decodes as UTF16-LE (strictly), which is a pretty good guess. On unix this decodes as UTF8 (strictly), which is a good guess.

Throws a EncodingException if decoding fails.

valuedecodeFS :: OsPath -> IO FilePath
#

Like decodeUtf, except this mimics the behavior of the base library when doing filesystem operations, which is:

  1. on unix, uses shady PEP 383 style encoding (based on the current locale, but PEP 383 only works properly on UTF-8 encodings, so good luck)

  2. on windows does permissive UTF-16 encoding, where coding errors generate Chars in the surrogate range

Looking up the locale requires IO. If you're not worried about calls to setFileSystemEncoding, then unsafePerformIO may be feasible (make sure to deeply evaluate the result to catch exceptions).

valueosp :: QuasiQuoter
#

QuasiQuote an OsPath. This accepts Unicode characters and encodes as UTF-8 on unix and UTF-16LE on windows. Runs isValid on the input. If used as a pattern, requires turning on the ViewPatterns extension.

valuepack :: [OsChar] -> OsPath
#

Pack a list of OsChar to an OsPath.

Note that using this in conjunction with unsafeFromChar to convert from [Char] to OsPath is probably not what you want, because it will truncate unicode code points.