filepath-2.0.0.0: Library for manipulating FilePaths in a cross platform way.
Safe HaskellNone
LanguageHaskell2010

System.OsString.Posix

Synopsis

Types

data PosixString Source #

Commonly used Posix string as uninterpreted char[] array.

Instances

Instances details
Eq PosixString Source # 
Instance details

Defined in System.OsString.Internal.Types

Ord PosixString Source # 
Instance details

Defined in System.OsString.Internal.Types

Read PosixString Source #

Encodes as UTF-8.

Instance details

Defined in System.OsString.Internal.Types

Show PosixString Source #

Decodes as UTF-8 and replaces invalid chars with unicode replacement char U+FFFD.

Instance details

Defined in System.OsString.Internal.Types

IsString PosixString Source # 
Instance details

Defined in System.OsString.Internal.Types

Generic PosixString Source # 
Instance details

Defined in System.OsString.Internal.Types

Associated Types

type Rep PosixString :: Type -> Type #

Semigroup PosixString Source # 
Instance details

Defined in System.OsString.Internal.Types

Monoid PosixString Source # 
Instance details

Defined in System.OsString.Internal.Types

NFData PosixString Source # 
Instance details

Defined in System.OsString.Internal.Types

Methods

rnf :: PosixString -> () #

Lift PosixString Source # 
Instance details

Defined in System.OsString.Internal.Types

type Rep PosixString Source # 
Instance details

Defined in System.OsString.Internal.Types

type Rep PosixString = D1 ('MetaData "PosixString" "System.OsString.Internal.Types" "filepath-2.0.0.0-inplace" 'True) (C1 ('MetaCons "PS" 'PrefixI 'True) (S1 ('MetaSel ('Just "unPFP") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ShortByteString)))

data PosixChar Source #

Instances

Instances details
Eq PosixChar Source # 
Instance details

Defined in System.OsString.Internal.Types

Ord PosixChar Source # 
Instance details

Defined in System.OsString.Internal.Types

Show PosixChar Source # 
Instance details

Defined in System.OsString.Internal.Types

Generic PosixChar Source # 
Instance details

Defined in System.OsString.Internal.Types

Associated Types

type Rep PosixChar :: Type -> Type #

NFData PosixChar Source # 
Instance details

Defined in System.OsString.Internal.Types

Methods

rnf :: PosixChar -> () #

type Rep PosixChar Source # 
Instance details

Defined in System.OsString.Internal.Types

type Rep PosixChar = D1 ('MetaData "PosixChar" "System.OsString.Internal.Types" "filepath-2.0.0.0-inplace" 'True) (C1 ('MetaCons "PW" 'PrefixI 'True) (S1 ('MetaSel ('Just "unPW") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Word8)))

String construction

toPlatformString :: String -> PosixString Source #

Total Unicode-friendly encoding.

On windows this encodes as UTF16, which is expected. On unix this encodes as UTF8, which is a good guess.

toPlatformStringIO :: String -> IO PosixString Source #

Like toPlatformString, except on unix this uses the current locale for encoding instead of always UTF8.

Looking up the locale requires IO. If you're not worried about calls to setFileSystemEncoding, then unsafePerformIO may be feasible.

bsToPlatformString :: MonadThrow m => ByteString -> m PosixString Source #

Constructs an platform string from a ByteString.

On windows, this ensures valid UTF16, on unix it is passed unchanged/unchecked.

Throws UnicodeException on invalid UTF16 on windows.

pstr :: QuasiQuoter Source #

QuasiQuote a PosixString. This accepts Unicode characters and encodes as UTF-8 on unix.

String deconstruction

fromPlatformString :: MonadThrow m => PosixString -> m String Source #

Partial unicode friendly decoding.

On windows this decodes as UTF16 (which is the expected filename encoding). On unix this decodes as UTF8 (which is a good guess). Note that filenames on unix are encoding agnostic char arrays.

Throws a UnicodeException if decoding fails.

fromPlatformStringEnc :: PosixString -> TextEncoding -> Either UnicodeException String Source #

Like fromPlatformString, except on unix this uses the provided TextEncoding for decoding.

fromPlatformStringIO :: PosixString -> IO String Source #

Like fromPlatformString, except on unix this uses the current locale for decoding instead of always UTF8.

Looking up the locale requires IO. If you're not worried about calls to setFileSystemEncoding, then unsafePerformIO may be feasible.

Throws UnicodeException if decoding fails.

Word construction

unsafeFromChar :: Char -> PosixChar Source #

Truncates to 1 octet.

Word deconstruction

toChar :: PosixChar -> Char Source #

Converts back to a unicode codepoint (total).